diff options
| author | Fuwn <[email protected]> | 2026-02-12 04:19:29 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-02-12 04:19:29 -0800 |
| commit | 285cd8c3abe8fe9f4fe271c79cbe63f238e8e4cc (patch) | |
| tree | 8a528bbe904ad766a7c973df544627f8e9edd29c /apps | |
| parent | fix: prioritise unread entries server-side so they appear in all-entries view (diff) | |
| download | asa.news-285cd8c3abe8fe9f4fe271c79cbe63f238e8e4cc.tar.xz asa.news-285cd8c3abe8fe9f4fe271c79cbe63f238e8e4cc.zip | |
fix: keep scroll position stable when entry list re-sorts after read state change
Diffstat (limited to 'apps')
| -rw-r--r-- | apps/web/app/reader/_components/entry-list.tsx | 13 |
1 files 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 ( |