From 285cd8c3abe8fe9f4fe271c79cbe63f238e8e4cc Mon Sep 17 00:00:00 2001 From: Fuwn Date: Thu, 12 Feb 2026 04:19:29 -0800 Subject: fix: keep scroll position stable when entry list re-sorts after read state change --- apps/web/app/reader/_components/entry-list.tsx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/apps/web/app/reader/_components/entry-list.tsx b/apps/web/app/reader/_components/entry-list.tsx index ee2dad2..3623c63 100644 --- a/apps/web/app/reader/_components/entry-list.tsx +++ b/apps/web/app/reader/_components/entry-list.tsx @@ -159,17 +159,18 @@ export function EntryList({ allEntriesReference.current = allEntries useEffect(() => { - if (!focusedEntryIdentifier) return + const activeIdentifier = focusedEntryIdentifier ?? selectedEntryIdentifier + if (!activeIdentifier) return - const focusedIndex = allEntriesReference.current.findIndex( - (entry) => entry.entryIdentifier === focusedEntryIdentifier + const activeIndex = allEntriesReference.current.findIndex( + (entry) => entry.entryIdentifier === activeIdentifier ) - if (focusedIndex !== -1) { - virtualizer.scrollToIndex(focusedIndex, { align: "auto" }) + if (activeIndex !== -1) { + virtualizer.scrollToIndex(activeIndex, { align: "auto" }) } // eslint-disable-next-line react-hooks/exhaustive-deps - }, [focusedEntryIdentifier]) + }, [focusedEntryIdentifier, allEntries]) if (isLoading) { return ( -- cgit v1.2.3