fix(timeline): trigger scroll-to-today on isInitialLoading→false not totalCanvasWidth
CI / Architecture Guardrails (pull_request) Successful in 2m53s
CI / Typecheck (pull_request) Successful in 3m28s
CI / Assistant Split Regression (pull_request) Successful in 3m40s
CI / Lint (pull_request) Successful in 4m26s
CI / Unit Tests (pull_request) Successful in 8m36s
CI / Build (pull_request) Successful in 9m47s
CI / E2E Tests (pull_request) Failing after 14m2s
CI / Fresh-Linux Docker Deploy (pull_request) Successful in 16m53s
CI / Release Images (pull_request) Has been skipped

totalCanvasWidth is computed from viewStart/viewDays before data loads,
so the previous trigger fired during the loading spinner. scrollLeft
was clipped to 0 (no canvas in DOM yet) and the guard was set, blocking
the real scroll after data arrived. Using isInitialLoading as the dep
fires the effect exactly when the canvas enters the DOM.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-22 08:48:23 +02:00
parent 0e9d6ec388
commit 2383bcbdc0
@@ -698,16 +698,16 @@ function TimelineViewContent({
}; };
}, []); }, []);
// Scroll to today the first time the canvas has its full width (after initial data load). // Scroll to today the first time the canvas is in the DOM (isInitialLoading → false).
// Depends on totalCanvasWidth so it fires after isInitialLoading → false renders the canvas. // totalCanvasWidth is non-zero before data loads, so it can't be used as the trigger.
useLayoutEffect(() => { useLayoutEffect(() => {
if (totalCanvasWidth === 0) return; if (isInitialLoading) return;
if (hasScrolledToTodayOnLoad.current) return; if (hasScrolledToTodayOnLoad.current) return;
const el = scrollContainerRef.current; const el = scrollContainerRef.current;
if (!el) return; if (!el) return;
el.scrollLeft = toLeft(today); el.scrollLeft = toLeft(today);
hasScrolledToTodayOnLoad.current = true; hasScrolledToTodayOnLoad.current = true;
}, [totalCanvasWidth, toLeft, today]); }, [isInitialLoading, toLeft, today]);
// Apply scroll compensation synchronously after the canvas grows (left-extend or Today button). // Apply scroll compensation synchronously after the canvas grows (left-extend or Today button).
useLayoutEffect(() => { useLayoutEffect(() => {