From 774e567317a0ae6492793a21c612115e00c2e8b1 Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Tue, 30 Dec 2025 15:01:40 -0600 Subject: [PATCH] improve initial scroll to active item in detail stream --- web/src/components/timeline/DetailStream.tsx | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/web/src/components/timeline/DetailStream.tsx b/web/src/components/timeline/DetailStream.tsx index c18cf9dff..a325a54f3 100644 --- a/web/src/components/timeline/DetailStream.tsx +++ b/web/src/components/timeline/DetailStream.tsx @@ -100,7 +100,25 @@ export default function DetailStream({ } }, [reviewItems, activeReviewId, effectiveTime]); - // Auto-scroll to current time + // Initial scroll to active review (runs immediately when user selects, not during playback) + useEffect(() => { + if (!scrollRef.current || !activeReviewId || userInteracting || isPlaying) + return; + + const element = scrollRef.current.querySelector( + `[data-review-id="${activeReviewId}"]`, + ) as HTMLElement; + + if (element) { + setProgrammaticScroll(); + scrollIntoView(element, { + scrollMode: "if-needed", + behavior: "smooth", + }); + } + }, [activeReviewId, setProgrammaticScroll, userInteracting, isPlaying]); + + // Auto-scroll to current time during playback useEffect(() => { if (!scrollRef.current || userInteracting || !isPlaying) return; // Prefer the review whose range contains the effectiveTime. If none