From e86ac1fbb1ba98f853320d0bd36fe4e24ec29b8e Mon Sep 17 00:00:00 2001 From: Janic Duplessis Date: Tue, 6 Feb 2024 16:01:55 -0500 Subject: [PATCH] Fix onStartReached not called when list content is small --- .../virtualized-lists/Lists/VirtualizedList.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/virtualized-lists/Lists/VirtualizedList.js b/packages/virtualized-lists/Lists/VirtualizedList.js index 8638f5f80f812e..9f950916a2dfc0 100644 --- a/packages/virtualized-lists/Lists/VirtualizedList.js +++ b/packages/virtualized-lists/Lists/VirtualizedList.js @@ -1548,7 +1548,7 @@ class VirtualizedList extends StateSafePureComponent { // Next check if the user just scrolled within the start threshold // and call onStartReached only once for a given content length, // and only if onEndReached is not being executed - else if ( + if ( onStartReached != null && this.state.cellsAroundViewport.first === 0 && isWithinStartThreshold && @@ -1560,13 +1560,11 @@ class VirtualizedList extends StateSafePureComponent { // If the user scrolls away from the start or end and back again, // cause onStartReached or onEndReached to be triggered again - else { - this._sentStartForContentLength = isWithinStartThreshold - ? this._sentStartForContentLength - : 0; - this._sentEndForContentLength = isWithinEndThreshold - ? this._sentEndForContentLength - : 0; + if (!isWithinStartThreshold) { + this._sentStartForContentLength = 0; + } + if (!isWithinEndThreshold) { + this._sentEndForContentLength = 0; } }