diff --git a/frontend/src/components/list/MessageList.tsx b/frontend/src/components/list/MessageList.tsx index cc094fe..82ede33 100644 --- a/frontend/src/components/list/MessageList.tsx +++ b/frontend/src/components/list/MessageList.tsx @@ -1,6 +1,6 @@ import { useQuery } from "@tanstack/react-query"; import { useVirtualizer } from "@tanstack/react-virtual"; -import { useRef } from "react"; +import { useEffect, useRef } from "react"; import { useT } from "../../i18n"; import { api } from "../../lib/api"; @@ -56,6 +56,7 @@ function Paperclip() { // Virtualized thread list (SPEC ยง2 list/MessageList.tsx). export function MessageList({ threads, + page, selectedId, folder, onSelect, @@ -69,6 +70,8 @@ export function MessageList({ onToggleCheck, }: { threads: ThreadSummary[]; + /** Which page of the list this is. Changing it scrolls back to the top. */ + page: number; selectedId?: string; folder: string; onSelect: (id: string) => void; @@ -106,6 +109,12 @@ export function MessageList({ overscan: 8, }); + // A new page starts at the top. Paging while scrolled down would otherwise + // drop you into the middle of the next fifty with no sense of having moved. + useEffect(() => { + parentRef.current?.scrollTo({ top: 0 }); + }, [page]); + if (threads.length === 0) { return