From 1492afcb591567decc01934c0c8d1c3688e9bef3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Kwas=CC=81niewski?= Date: Thu, 6 Apr 2023 22:01:59 +0200 Subject: [PATCH] fix: make sure initialScrollIndex is bigger than 0 --- packages/virtualized-lists/Lists/VirtualizedList.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/virtualized-lists/Lists/VirtualizedList.js b/packages/virtualized-lists/Lists/VirtualizedList.js index de44f303b07ce9..bdccaecfb40a22 100644 --- a/packages/virtualized-lists/Lists/VirtualizedList.js +++ b/packages/virtualized-lists/Lists/VirtualizedList.js @@ -616,7 +616,7 @@ class VirtualizedList extends StateSafePureComponent { ), }; } else { - // If we have a non-zero initialScrollIndex and run this before we've scrolled, + // If we have a positive non-zero initialScrollIndex and run this before we've scrolled, // we'll wipe out the initialNumToRender rendered elements starting at initialScrollIndex. // So let's wait until we've scrolled the view to the right place. And until then, // we will trust the initialScrollIndex suggestion. @@ -627,7 +627,7 @@ class VirtualizedList extends StateSafePureComponent { // - initialScrollIndex > 0 AND the end of the list is visible (this handles the case // where the list is shorter than the visible area) if ( - props.initialScrollIndex && + (props.initialScrollIndex == null || props.initialScrollIndex >= 0) && !this._scrollMetrics.offset && Math.abs(distanceFromEnd) >= Number.EPSILON ) {