Repository navigation
Conversation
…he anchor out of the rendered window
Author
|
I have signed the CLA. |
This branch has not been deployed
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.
Problem
applyOffsetCorrectionlooks for the tracked first visible item (the anchor) among the engaged indices first, and falls back to a fulldatasearch only when data length changed or a previous correction is still settling (ignoreScrollEvents).There is a third case: items above the anchor were estimates (or the running estimate changes) and turn out much smaller when measured. The anchor's layout then moves up by the total difference, the next layout pass recomputes the engaged window at the unchanged scroll offset, and the anchor is no longer in it — although the user has not scrolled and the anchor is still the item on screen. The engaged search misses, the fallback is skipped, and no correction is applied at all: the content jumps by the full difference (easily hundreds of pixels after a few smaller-than-estimated items).
Fix
Also take the full-data fallback when the anchor, as recorded, still overlaps the viewport. An anchor the user scrolled away from does not qualify, so the existing behaviour for genuine scrolls is unchanged.
Tests
New
src/__tests__/useRecyclerViewController.test.tsx(hook rendered with a realRecyclerViewManager; layout passes driven likeRecyclerView's layout effect: measure → re-render passes → correction):main(Expected: -9000, Received: 0), passes with the fix.Verified locally on the published
srcof 2.3.3 (identical tomain) with Jest.Notes
data, the same search already used for the other two cases; it only runs when the engaged search missed and the anchor is still on screen.