From 186431fab36fa3729464b4c1d984a365ebe4f0f1 Mon Sep 17 00:00:00 2001 From: Shuhei Takahashi Date: Mon, 2 May 2022 23:09:07 +0900 Subject: [PATCH] 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 #1109 --- src/views/app/components/LibraryManager.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/views/app/components/LibraryManager.tsx b/src/views/app/components/LibraryManager.tsx index 0bf6bc33..f7a08b03 100644 --- a/src/views/app/components/LibraryManager.tsx +++ b/src/views/app/components/LibraryManager.tsx @@ -137,6 +137,10 @@ class LibraryManager extends React.Component { + // On updating a list, ReactList can call itemRenderer with large indices. + if (index >= filteredLibraries.length) { + return null; + } return (); }; const itemSizeEstimator = (index, cache) => {