Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,8 @@ 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 != null &&
props.initialScrollIndex > 0 &&
!this._scrollMetrics.offset &&
Math.abs(distanceFromEnd) >= Number.EPSILON
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3122,12 +3122,53 @@ exports[`gracefully handles negative initialScrollIndex 1`] = `
/>
</View>
<View
style={
Object {
"height": 60,
}
}
/>
onFocusCapture={[Function]}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change expected? It looks this is the snapshot from

it('gracefully handles negative initialScrollIndex', () => {

which lists initialNumToRender as 4

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the snapshot is taken after we run fake layout and timers (after initial render), so I think this is showing that we are now rendering cells we previously failed to.

style={null}
>
<MockCellItem
value={4}
/>
</View>
<View
onFocusCapture={[Function]}
style={null}
>
<MockCellItem
value={5}
/>
</View>
<View
onFocusCapture={[Function]}
style={null}
>
<MockCellItem
value={6}
/>
</View>
<View
onFocusCapture={[Function]}
style={null}
>
<MockCellItem
value={7}
/>
</View>
<View
onFocusCapture={[Function]}
style={null}
>
<MockCellItem
value={8}
/>
</View>
<View
onFocusCapture={[Function]}
style={null}
>
<MockCellItem
value={9}
/>
</View>
</View>
</RCTScrollView>
`;
Expand Down