Skip to content

Fix scroll target after dataKey switch - #579

Open
jmeistrich wants to merge 11 commits into
mainfrom
fix/data-key-switch-scroll-target
Open

jmeistrich wants to merge 11 commits into
mainfrom
fix/data-key-switch-scroll-target

Conversation

@jmeistrich

Copy link
Copy Markdown
Member

What was broken

After a dataKey switch, a pending initial scroll target could resolve against stale layout from the previous data, so the list landed on the wrong row or never confirmed it had landed.

Fix

  • Destination geometry is prepared before the scroll target resolves, so the target uses the new data's layout.
  • Web scroll completion uses an inclusive 1px tolerance, confirmed from the DOM, so instant scrolls that land within a pixel complete.
  • When recycleItems={false}, the container pool prefers empty cells over reusing occupied ones.
  • Horizontal RTL on web uses negative offsets before the first scroll, so cold RTL mounts land without extra scroll calls.

Verification

  • Tests: 799 passed, 0 failed; tsc, lint and build pass.
  • Chromium stale-target repro: 9/9 (base 5/9).
  • Cold horizontal RTL: 5/5 (base 0/5).
  • Adjacent web flows (vertical, LTR, offset, prepend, end-follow): 32/32.
  • Web only; native was not run, since the changes are in web paths.
  • Known limit inherited from main: RTL prepend still sends a wrong scrollBy.

Intended to merge after 3.7.0 ships.

Retire fresh-data scroll ownership before preparing destination positions,
then reuse that data epoch during container allocation instead of clearing
the same geometry twice. Keep keyed measurements and the container pool.

Invalidate column-dependent measurements before preparation and discard
unconsumed epochs when a viewport cannot allocate. Cover active bootstrap
data updates, uncached switches, first destination windows, and epoch reuse.
Check the normalized observed offset against the current target on the
completion frame and synchronize settled scroll state before finishing.
Keep the existing completion fallback when the DOM cannot confirm landing.

Share inclusive one-pixel tolerance across watchdog, completion, and layout
correction. Cover RTL offsets, footer and viewport changes, stale callbacks,
and the exact one-pixel completion boundary.
Use empty normal cells before evicting assigned cells, including typed and pending-removal candidates. Keep type matching within each pool and preserve recycling behavior.
Prepare data geometry early only for fresh datasets and active bootstrap sessions so settling offset sessions retain their pre-change MVCP anchors. Remove the preparation epoch and always invalidate column measurements when columns change, including deferred allocation.
Feed unaligned observed offsets into initial-scroll fallback checks so optimistic dispatch state cannot complete an unconfirmed request immediately. Preserve next-frame completion for custom scrollers that do not expose offset observation.
Use one observed-offset assignment for confirmed completions and initial-scroll fallback checks. Preserve the existing completion predicate, finite-observation guard, custom-scroller contract, and animated landing retries.

Validation: 530 targeted tests across 22 files, full typecheck, lint, library build, and headless Chromium switch/completion checks.
Use the primary scroll path coordinate conversion when retrying an initial or end target through the completion fallback. Logical offsets must be translated before dispatching to the native scroller.

Cover an initial landing two pixels short in negative and inverted RTL modes. Both retries reach logical offset 1500 instead of reversing to 0 or 8000.
Capture positions and the column count when the first destination bootstrap is assigned, before later layout passes can repair stale geometry. Cover one-pixel and beyond-one-pixel end-clamp overshoot on web, iOS, and Android.
Keep resetColumnLayoutCaches in the shared cache module so initial scroll lifecycle no longer imports checkResetContainers through the calculateItemsInView cycle. Both callers reuse the unchanged reset implementation.
Skip the preference pool when it has no candidates, avoiding the exact-type, untyped, and cross-type request scans. Preserve matching order whenever empty cells are available.
Default web RTL coordinates to negative offsets so a cold initial target lands without waiting for a negative scroll event to classify the mode. Preserve that mode at zero instead of reclassifying the start as inverted.

Cover cold initial landing and next-frame completion without fallback dispatches, initial zero observations, and returning to zero. Keep native defaults and explicitly detected coordinate modes.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-21T16:41:00.400043Z
We couldn’t complete this review. Comment @codex review to try again.
28406f0 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant