Skip to content

Commit

Permalink
fix: make sure initialScrollIndex is bigger than 0
Browse files Browse the repository at this point in the history
  • Loading branch information
okwasniewski committed Apr 6, 2023
1 parent 610b14e commit f05d994
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/virtualized-lists/Lists/VirtualizedList.js
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
),
};
} 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.
Expand All @@ -627,7 +627,7 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
// - 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 > 0 &&
!this._scrollMetrics.offset &&
Math.abs(distanceFromEnd) >= Number.EPSILON
) {
Expand Down Expand Up @@ -1752,6 +1752,7 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
};

_updateCellsToRender = () => {
console.warn('updateCellsToRender')
this._updateViewableItems(this.props, this.state.cellsAroundViewport);

this.setState((state, props) => {
Expand Down

0 comments on commit f05d994

Please sign in to comment.