Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make sure initialScrollIndex is bigger than 0 #36844

Conversation

okwasniewski
Copy link
Contributor

@okwasniewski okwasniewski commented Apr 6, 2023

Summary:

Hey,

adjustCellsAroundViewport function was checking if props.initialScrollIndex is truthy and -1 was returning true. This caused bugs with rendering for tvOS: react-native-tvos/react-native-tvos#485 There are warnings in the code about initalScrollIndex being smaller than 0 but this if statement would still allow that.

Changelog:

[General] [Fixed] - Make sure initialScrollToIndex is bigger than 0 when adjusting cells

Test Plan:

Pass -1 as initialScrollToIndex. Check that this code is executed.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 6, 2023
@okwasniewski okwasniewski force-pushed the fix/@okwasniewski/initalScrollToIndex branch from f05d994 to c6562b9 Compare April 6, 2023 20:08
@okwasniewski okwasniewski force-pushed the fix/@okwasniewski/initalScrollToIndex branch 2 times, most recently from 1492afc to 07d4d0e Compare April 6, 2023 20:18
@okwasniewski okwasniewski force-pushed the fix/@okwasniewski/initalScrollToIndex branch from 07d4d0e to 41c9940 Compare April 6, 2023 20:23
@analysis-bot
Copy link

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 8,604,282 -331
android hermes armeabi-v7a 7,918,183 -340
android hermes x86 9,090,142 -339
android hermes x86_64 8,945,230 -335
android jsc arm64-v8a 9,173,715 -118
android jsc armeabi-v7a 8,365,393 -100
android jsc x86 9,231,370 -118
android jsc x86_64 9,490,080 -101

Base commit: a27270f
Branch: main

}
}
/>
onFocusCapture={[Function]}
Copy link
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
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.

@NickGerleman
Copy link
Contributor

NickGerleman commented Apr 7, 2023

It would be a good idea to re-test this against current VirtualizedList, if this issue was happening on tvOS using 0.69. There have been some large changes since then.

The change makes sense at a glance, and the snapshot change I think is showing the described bug fixed. But it would be helpful to also include the code this is triggering which causes the issue (it's hard to tell just from this condition).

@okwasniewski
Copy link
Contributor Author

@NickGerleman Thanks for reviewing the changes. It looks like the new list (from master) on tvOS is working as expected and the bug with rendering only first batch of items is fixed. I can't reproduce this now, maybe some other scenario will.

Let me know if you want to merge this change or I should close this PR.

@NickGerleman
Copy link
Contributor

Snapshots make it look like this is still fixing a bug on main, so change makes sense to me. I am currently on vacation and away from internal tools, but someone else should be able to merge.

@facebook-github-bot
Copy link
Contributor

@lunaleaps has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Apr 18, 2023
@facebook-github-bot
Copy link
Contributor

@NickGerleman merged this pull request in eb30a80.

bang9 pushed a commit to bang9/react-native that referenced this pull request May 4, 2023
Summary:
Hey,

`adjustCellsAroundViewport` function was checking if `props.initialScrollIndex` is truthy and -1 was returning true. This caused bugs with rendering for tvOS: react-native-tvos/react-native-tvos#485 There are warnings in the code about `initalScrollIndex` being smaller than 0 but this if statement would still allow that.

## Changelog:

[General] [Fixed] - Make sure initialScrollToIndex is bigger than 0 when adjusting cells

Pull Request resolved: facebook#36844

Test Plan: Pass -1 as initialScrollToIndex. Check that this code is executed.

Reviewed By: cipolleschi

Differential Revision: D44856266

Pulled By: NickGerleman

fbshipit-source-id: 781a1c0efeae93f00766eede4a42559dcd066d7d
jeongshin pushed a commit to jeongshin/react-native that referenced this pull request May 7, 2023
Summary:
Hey,

`adjustCellsAroundViewport` function was checking if `props.initialScrollIndex` is truthy and -1 was returning true. This caused bugs with rendering for tvOS: react-native-tvos/react-native-tvos#485 There are warnings in the code about `initalScrollIndex` being smaller than 0 but this if statement would still allow that.

## Changelog:

[General] [Fixed] - Make sure initialScrollToIndex is bigger than 0 when adjusting cells

Pull Request resolved: facebook#36844

Test Plan: Pass -1 as initialScrollToIndex. Check that this code is executed.

Reviewed By: cipolleschi

Differential Revision: D44856266

Pulled By: NickGerleman

fbshipit-source-id: 781a1c0efeae93f00766eede4a42559dcd066d7d
OlimpiaZurek pushed a commit to OlimpiaZurek/react-native that referenced this pull request May 22, 2023
Summary:
Hey,

`adjustCellsAroundViewport` function was checking if `props.initialScrollIndex` is truthy and -1 was returning true. This caused bugs with rendering for tvOS: react-native-tvos/react-native-tvos#485 There are warnings in the code about `initalScrollIndex` being smaller than 0 but this if statement would still allow that.

## Changelog:

[General] [Fixed] - Make sure initialScrollToIndex is bigger than 0 when adjusting cells

Pull Request resolved: facebook#36844

Test Plan: Pass -1 as initialScrollToIndex. Check that this code is executed.

Reviewed By: cipolleschi

Differential Revision: D44856266

Pulled By: NickGerleman

fbshipit-source-id: 781a1c0efeae93f00766eede4a42559dcd066d7d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants