From 6b2bbcf63203e49d2806c8a684f82bc63b7b10a0 Mon Sep 17 00:00:00 2001 From: generatedunixname89002005232357 Date: Tue, 8 Oct 2024 12:13:10 -0700 Subject: [PATCH] Revert D63643856 Summary: This diff reverts D63643856 `_highestMeasuredFrameIndex` is not properly invalidated causing issues with previous logic when data size shrinks. bypass-github-export-checks Changelog: [General][Changed] - Revert "Fix onEndReached not being called when getItemLayout is present and we scroll past render window" Reviewed By: NickGerleman Differential Revision: D64009287 fbshipit-source-id: 8a21b57f5247fc743e65f9a730ff33a9a89d2bc1 --- .../virtualized-lists/Lists/VirtualizedList.js | 18 ------------------ .../Lists/__tests__/VirtualizedList-test.js | 14 +++++--------- 2 files changed, 5 insertions(+), 27 deletions(-) diff --git a/packages/virtualized-lists/Lists/VirtualizedList.js b/packages/virtualized-lists/Lists/VirtualizedList.js index e91f73cb898..588e3ed9d38 100644 --- a/packages/virtualized-lists/Lists/VirtualizedList.js +++ b/packages/virtualized-lists/Lists/VirtualizedList.js @@ -1181,12 +1181,6 @@ class VirtualizedList extends StateSafePureComponent { if (hiPriInProgress) { this._hiPriInProgress = false; } - - // We only call `onEndReached` after we render the last cell, but when - // getItemLayout is present, we can scroll past the last rendered cell, and - // never trigger a new layout or bounds change, so we need to check again - // after rendering more cells. - this._maybeCallOnEdgeReached(); } _cellRefs: {[string]: null | CellRenderer} = {}; @@ -1497,20 +1491,11 @@ class VirtualizedList extends StateSafePureComponent { const { data, getItemCount, - getItemLayout, onStartReached, onStartReachedThreshold, onEndReached, onEndReachedThreshold, } = this.props; - // Wait until we have real metrics - if ( - !this._listMetrics.hasContentLength() || - this._scrollMetrics.visibleLength === 0 - ) { - return; - } - // If we have any pending scroll updates it means that the scroll metrics // are out of date and we should not call any of the edge reached callbacks. if (this.state.pendingScrollUpdateCount > 0) { @@ -1553,9 +1538,6 @@ class VirtualizedList extends StateSafePureComponent { if ( onEndReached && this.state.cellsAroundViewport.last === getItemCount(data) - 1 && - (getItemLayout != null || - this._listMetrics.getHighestMeasuredCellIndex() === - getItemCount(data) - 1) && isWithinEndThreshold && this._listMetrics.getContentLength() !== this._sentEndForContentLength ) { diff --git a/packages/virtualized-lists/Lists/__tests__/VirtualizedList-test.js b/packages/virtualized-lists/Lists/__tests__/VirtualizedList-test.js index 1c7f7f92dc4..78648590d69 100644 --- a/packages/virtualized-lists/Lists/__tests__/VirtualizedList-test.js +++ b/packages/virtualized-lists/Lists/__tests__/VirtualizedList-test.js @@ -663,6 +663,11 @@ describe('VirtualizedList', () => { renderItem: ({item}) => , getItem: (items, index) => items[index], getItemCount: items => items.length, + getItemLayout: (items, index) => ({ + length: ITEM_HEIGHT, + offset: ITEM_HEIGHT * index, + index, + }), onEndReached, }; @@ -689,15 +694,6 @@ describe('VirtualizedList', () => { expect(onEndReached).not.toHaveBeenCalled(); await act(() => { - for (let i = 0; i < 20; ++i) { - simulateCellLayout(component, data, i, { - width: 10, - height: ITEM_HEIGHT, - x: 0, - y: i * ITEM_HEIGHT, - }); - } - instance._onScroll({ timeStamp: 1000, nativeEvent: {