Skip to content

Commit 186431f

Browse files
committed
Fix library search result rendering
ReactList may call itemRenderer with an index larger than list length when the component is being updated. Failing to handle the case causes the rendering to break due to an unhandled exception. For example, try searching for "audioq". Until one types "audio", search results are correctly narrowed, but typing the final letter "q" does not update the results to zero due to an unhandled exception. This patch fixes the issue by handling out of band indices in itemRenderer. Fixes microsoft#1109
1 parent 943196e commit 186431f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/views/app/components/LibraryManager.tsx

+4
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ class LibraryManager extends React.Component<ILibraryManagerProps, ILibraryManag
137137
const isOperating = !!this.props.installingLibraryName || !!this.props.uninstallingLibraryName;
138138

139139
const itemRenderer = (index, key) => {
140+
// On updating a list, ReactList can call itemRenderer with large indices.
141+
if (index >= filteredLibraries.length) {
142+
return null;
143+
}
140144
return (<LibraryItemView key={filteredLibraries[index].name} library={filteredLibraries[index]} {...libraryItemProps}/>);
141145
};
142146
const itemSizeEstimator = (index, cache) => {

0 commit comments

Comments
 (0)