Fix FlatList initialScrollIndex behavior when short list fits viewport#56262
Conversation
|
Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Summary:
This PR fixes a bug in
VirtualizedList(and thusFlatList) where settinginitialScrollIndexto a non-zero value prevents items before it from rendering if the entire list fits within the viewport.The issue was that
VirtualizedListblocks render window updates when there is apendingScrollUpdateCount > 0. However, when the content fits the screen, a scroll event is never triggered to clear that pending update, leaving preceding items unrendered. This fix ensures that updates are only blocked if the content is large enough to scroll (contentLength > visibleLength).Fixes #56237
Changelog:
[ANDROID] [FIXED] - Fix FlatList initialScrollIndex behavior when short list fits viewport
Test Plan:
initialScrollIndex(e.g., Index 0, 1) are now correctly rendered when the list is short.yarn jest packages/virtualized-lists/Lists/VirtualizedList-test.js(Snapshots updated).