-
Notifications
You must be signed in to change notification settings - Fork 25k
Fix flatlist initialscrollindex 54409 #54466
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
base: main
Are you sure you want to change the base?
Fix flatlist initialscrollindex 54409 #54466
Conversation
- Fix setFeedbackUnderlay method to properly set view background - Resolves issue where ripple drawable was created but not applied - Fixes regression introduced by new background drawable system - Addresses issue facebook#54372
- Fix _initialRenderRegion to render all items when itemCount <= initialNumToRender - Fix _createRenderMask to apply scroll-to-top optimization for small lists with initialScrollIndex - Resolves issue where items before initialScrollIndex were not rendered - Ensures proper rendering order when entire list fits in viewport - Addresses issue facebook#54409
- Fix missing items before initialScrollIndex when entire list fits in viewport - Add validation for empty lists to prevent crashes - Preserve large list performance and accessibility behavior Fixes facebook#54409
- Limit fix to small lists (≤15 items) to preserve virtualization - Require initialScrollIndex > 0 to maintain accessibility focus - Prevent scroll UP issues and first item rendering problems - Maintain original behavior for larger lists Addresses reported issues while keeping the core bug fix
- Only apply fix when getItemLayout is provided to prevent virtualization issues - Reduce item limit to 10 for more conservative approach - Fixes scroll UP issues and jumping behavior without getItemLayout - Maintains original behavior for lists without getItemLayout Resolves scroll and focus issues while preserving the core bug fix
| @JvmStatic | ||
| public fun setFeedbackUnderlay(view: View, drawable: Drawable?) { | ||
| ensureCompositeBackgroundDrawable(view).withNewFeedbackUnderlay(drawable) | ||
| view.background = ensureCompositeBackgroundDrawable(view).withNewFeedbackUnderlay(drawable) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this change is related to the list behavior. Could you revert this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this change is related to the list behavior. Could you revert this?
Hey actually i did this to resolve another issue that is #54455 .
can you check that PR too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cipolleschi review that PR too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cipolleschi review that PR too and this one and merge it?
@cipolleschi If you want i can revert it here?
| if (itemCount > 0 && | ||
| itemCount <= Math.min(initialNumToRender, 10) && | ||
| props.initialScrollIndex > 0 && | ||
| props.getItemLayout != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you do a check here for getItemLayout?
Summary:
Fixes #54409
When using
initialScrollIndexwith a FlatList where all items fit within the viewport, items before theinitialScrollIndexwere not being rendered. This caused missing items and incorrect rendering behavior.Root Cause: The
_initialRenderRegionmethod calculated the initial render region starting frominitialScrollIndexwithout considering if the entire list could fit in the viewport. Additionally, the_createRenderMaskmethod skipped the "scroll-to-top" optimization wheninitialScrollIndex > 0, preventing all items from being rendered.Solution:
_initialRenderRegionto render all items (0 to itemCount-1) whenitemCount <= initialNumToRenderandinitialScrollIndexis set_createRenderMaskto apply the scroll-to-top optimization for small lists even wheninitialScrollIndex > 0Changelog:
[GENERAL] [FIXED] - Fix FlatList initialScrollIndex missing items when entire list fits in viewport
Test Plan:
Test Case 1: Bug Reproduction