diff --git a/components/StudyFeed.tsx b/components/StudyFeed.tsx index 9735495..41cd792 100644 --- a/components/StudyFeed.tsx +++ b/components/StudyFeed.tsx @@ -49,7 +49,8 @@ export function StudyFeed({ deck }: { deck: Deck }) { const next = useCallback(() => goTo(index + 1), [goTo, index]); - // Track which slide is visible (works for wheel, touch and programmatic scroll). + // Track which slide is visible (works for wheel, touch and programmatic + // scroll). Re-attached whenever the scroller remounts on a new run (runId). useEffect(() => { const container = scrollRef.current; if (!container) return; @@ -67,7 +68,7 @@ export function StudyFeed({ deck }: { deck: Deck }) { container.removeEventListener("scroll", onScroll); cancelAnimationFrame(frame); }; - }, []); + }, [runId]); // Keyboard navigation. useEffect(() => { @@ -262,7 +263,12 @@ export function StudyFeed({ deck }: { deck: Deck }) { {/* Feed ------------------------------------------------------ */} + {/* The scroller remounts on every run (key={runId}) so it always + starts on the first slide with fresh scroll/snap state: a shrinking + queue or an interrupted smooth scroll can never leave the feed on a + stale, half-scrolled or blank position. */}