diff --git a/frontend/src/components/timeline/Timeline.tsx b/frontend/src/components/timeline/Timeline.tsx index b6971f9..d33d621 100644 --- a/frontend/src/components/timeline/Timeline.tsx +++ b/frontend/src/components/timeline/Timeline.tsx @@ -247,6 +247,18 @@ export function Timeline() { prevSectionRef.current = currentSection didAutoFocusRef.current = false clearSelection() + // Reset scroll to the top of the new section. Without this the + // previous section's scroll offset (which can be tens of thousands + // of px in a long timeline) carries over to a freshly-loaded + // folder, leaving the user looking at empty space below the last + // row. The auto-focus effect below selects photos[0] on next + // render, but its "ensure visible" scroll only kicks in if the + // cell is out of view — by then the user has already seen the + // wrong scroll position. Doing this synchronously here keeps the + // first paint of the new section anchored at the top. + if (parentRef.current) { + parentRef.current.scrollTop = 0 + } }, [currentSection, clearSelection]) // Membership in the active heap (drives the green tint on each