fix(web): stop repeated scroll drift after deep timeline axis jumps #939
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/timeline-jump-drift"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
After a deep axis jump the timeline rendered as placeholder walls and then the scrollbar visibly jumped repeatedly (once per network round trip) until the view settled at the top of the library.
Root cause:
schedulePreviousDaysRevealCheckused inverted viewport geometry —sentinel.top < innerHeight + 900is trivially true when the top reveal sentinel sits above the viewport (its bottom is negative). After every hydration batch the check misfired,revealPreviousDaysprepended 8 day sections above the viewport without a mutation-time scroll anchor (protection PR #895 had removed), displacing the viewport and re-triggering the check: a deterministic feedback loop untilvisibleDayStartIndexhit 0.Changes
timelineReveal.ts(sentinelWithinRevealMargin: requiresrect.bottom >= 0) + 8 vitest casesrevealPreviousDays, composing with the hydrateDays merge-time anchor from #895 (delta-from-fresh-capture, never absolute Y)jumpingDayKeyis set; clear it in.finallyhtml:has(.timeline-owns-scroll) { overflow-anchor: none }) so JS is the single scroll ownercurrentScrollAnchorVerification
npm run test:unit: 27 passednpx playwright test tests/timeline.spec.ts: 81 passed, 0 failed (desktop+mobile)npm run check: 0 errors (20 pre-existing a11y warnings)After a deep axis jump the top reveal sentinel sits above the viewport and the reveal check's inverted geometry (top < margin, no bottom >= 0 test) misfired on every hydration batch: revealPreviousDays prepended 8 day sections above the viewport with no mutation-time anchor, displacing the viewport once per network round trip until visibleDayStartIndex hit 0 — the reported seconds-apart scrollbar jumps. - extract the reveal-margin predicate into timelineReveal.ts (sentinelWithinRevealMargin: requires rect.bottom >= 0 && rect.top < viewportHeight + 900) with unit tests - capture + restore the scroll anchor around the visible-window mutation in revealPreviousDays, composing with the hydrateDays merge-time anchor - suppress dayHydrationObserver, revealNextDays and the reveal check while jumpingDayKey is set; clear jumpingDayKey in .finally so a throw cannot wedge the settle gate; reset pendingPreviousDaysReveal on jump start - disable native scroll anchoring on the timeline route (html:has(.timeline-owns-scroll) { overflow-anchor: none }) — JS owns all scroll compensation there - skip the debounced state persist while jumping/hydrating (checked at schedule and fire time); the jump persists once at settle - prefer a viewport-intersecting tile in currentScrollAnchor over the first document-order tile below the top edge - add a Playwright regression test (fails on main: window drifts 20 -> 0) - bump apps/web 0.0.25 -> 0.0.26