-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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 last spacer constrain logic in VirtualizedList #41846
Fix last spacer constrain logic in VirtualizedList #41846
Conversation
I think this makes sense. Wonder if there other ways than MVCP adjustment we get into this state of "holes" in the measurements. I think that works fine most of the time under MVCP though (since the logic is supposed to avoid viewport shift on estimated layout change before viewport). |
@NickGerleman has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Yea I don’t think this logic is perfect since it is possible to shift outside the window if added items are very different than the estimate still. I wonder if there is a better way to handle this. |
Oh, one more MVCP issue on my radar was around Horizontal + RTL. I did a round of fixups to the platform scrollviews and FlatList for RTL, but MVCP wasn't working, and I didn't do the right thing to fix it. 30c7e9d |
I am currently working with Expensify to use MVCP in their app so we might end up hitting these issues too. |
@NickGerleman merged this pull request in 3ed4bf9. |
Summary: The logic to constrain the last spacer size is incorrect in some cases where the spacer is the last spacer, but not the last section in the list. For more context, the role of spacer constraining is explained in this comment: ``` // Without getItemLayout, we limit our tail spacer to the _highestMeasuredFrameIndex to // prevent the user for hyperscrolling into un-measured area because otherwise content will // likely jump around as it renders in above the viewport. ``` For example it is incorrect in the case where we have: ITEMS SPACER ITEMS In this case the spacer is not actually the tail spacer so the constraining is incorrectly appied. This causes issues mainly when using `maintainVisibleContentPosition` since it will cause it to scroll to an incorrect position and then cause the view that was supposed to stay visible to be virtualized away. ## Changelog: [GENERAL] [FIXED] - Fix last spacer constrain logic in VirtualizedList Pull Request resolved: #41846 Test Plan: Tested using https://gist.github.com/janicduplessis/b67d1fafc08ef848378263208ab93d4c in RN tester, before the change content will jump on first click on add items. Tested using the same example and setting initial posts to 1000, then we can see our content view size is still constrained properly (see scrolling indicator as reference). Reviewed By: yungsters Differential Revision: D51964500 Pulled By: NickGerleman fbshipit-source-id: 4465aa5a36c95466aef6571314973c1e2c9a0f2c
Summary: The logic to constrain the last spacer size is incorrect in some cases where the spacer is the last spacer, but not the last section in the list. For more context, the role of spacer constraining is explained in this comment: ``` // Without getItemLayout, we limit our tail spacer to the _highestMeasuredFrameIndex to // prevent the user for hyperscrolling into un-measured area because otherwise content will // likely jump around as it renders in above the viewport. ``` For example it is incorrect in the case where we have: ITEMS SPACER ITEMS In this case the spacer is not actually the tail spacer so the constraining is incorrectly appied. This causes issues mainly when using `maintainVisibleContentPosition` since it will cause it to scroll to an incorrect position and then cause the view that was supposed to stay visible to be virtualized away. ## Changelog: [GENERAL] [FIXED] - Fix last spacer constrain logic in VirtualizedList Pull Request resolved: facebook#41846 Test Plan: Tested using https://gist.github.com/janicduplessis/b67d1fafc08ef848378263208ab93d4c in RN tester, before the change content will jump on first click on add items. Tested using the same example and setting initial posts to 1000, then we can see our content view size is still constrained properly (see scrolling indicator as reference). Reviewed By: yungsters Differential Revision: D51964500 Pulled By: NickGerleman fbshipit-source-id: 4465aa5a36c95466aef6571314973c1e2c9a0f2c
Summary:
The logic to constrain the last spacer size is incorrect in some cases where the spacer is the last spacer, but not the last section in the list.
For more context, the role of spacer constraining is explained in this comment:
For example it is incorrect in the case where we have:
ITEMS
SPACER
ITEMS
In this case the spacer is not actually the tail spacer so the constraining is incorrectly appied.
This causes issues mainly when using
maintainVisibleContentPosition
since it will cause it to scroll to an incorrect position and then cause the view that was supposed to stay visible to be virtualized away.Changelog:
[GENERAL] [FIXED] - Fix last spacer constrain logic in VirtualizedList
Test Plan:
Tested using https://gist.github.com/janicduplessis/b67d1fafc08ef848378263208ab93d4c in RN tester, before the change content will jump on first click on add items.
Tested using the same example and setting initial posts to 1000, then we can see our content view size is still constrained properly (see scrolling indicator as reference).