fix(layout): prevent item overlap during fast scroll with dynamic heights#2196
Closed
github-actions[bot] wants to merge 1 commit intomainfrom
Closed
fix(layout): prevent item overlap during fast scroll with dynamic heights#2196github-actions[bot] wants to merge 1 commit intomainfrom
github-actions[bot] wants to merge 1 commit intomainfrom
Conversation
…ghts When items have dynamic heights and the average height estimate grows, the partial recomputation of layout positions creates a boundary where items in the recomputed range shift forward while items beyond it keep their old (lower) positions. The previous guard only checked the very last item's position against the recomputed range boundary, which missed cases where the immediately-next item had a stale position going backwards. This broke the monotonic ordering that binary search relies on, causing items to overlap and jump during fast scrolling. Fix the guard to check the item immediately after the recomputed range instead of the last item, detecting position discontinuities at the boundary and triggering a full recomputation when needed. Fixes #2175
This was referenced Mar 23, 2026
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.
Description
When FlashList items have dynamic heights and early items are measured with heights significantly different from the initial estimate, the layout recomputation only covers a limited range of items. The guard condition that decides whether to extend the recomputation checked only the very last item's position against the boundary, missing cases where items immediately after the recomputed range had stale positions going backwards. This broke the monotonic position ordering that the binary search relies on, causing items to overlap, jump, and collapse during fast scrolling.
The fix changes the guard to check the item immediately after the recomputed range instead of the last item, correctly detecting position discontinuities at the boundary and triggering full recomputation when needed.
Fixes #2175
Reviewers' hat-rack 🎩
Focus on the guard condition change in
_recomputeLayoutsinLayoutManager.ts. The key question is whether checkingnextPos < endPos(position of item at endIndex+1 vs position of item at endIndex) is the right heuristic for all layout types (linear, grid, masonry). For grid layouts, items in the same row share the same y, sonextPos < endPosshould only trigger across row boundaries when positions truly go backwards.Test plan
yarn test)yarn type-check)yarn lint)