fix(scroll): maintain scroll position when prepending large items#2138
Open
naqvitalha wants to merge 8 commits intomainfrom
Open
fix(scroll): maintain scroll position when prepending large items#2138naqvitalha wants to merge 8 commits intomainfrom
naqvitalha wants to merge 8 commits intomainfrom
Conversation
When large items are prepended, the scroll correction needs multiple passes to converge as unmeasured item heights settle. After the first correction pass, the anchor item could move outside the engaged indices window, and the fallback data search was gated behind hasDataChanged which was already false. This caused the second correction pass to fail to find the anchor, leaving the scroll at the wrong position. Track an isRefiningCorrection flag that allows subsequent correction passes to search the full data array for the anchor item and update the internal scroll offset until the correction converges. Fixes #2136
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
hasDataChanged, which was alreadyfalseby the second pass — so the anchor was lost and scroll stayed wrong.isRefiningCorrectionflag that keeps subsequent correction passes able to locate the anchor item and update the internal scroll offset until convergence. The flag piggybacks on the existingignoreScrollEventstimeout for cleanup.Test plan
yarn test— all 183 unit tests passFixes #2136