summaryrefslogtreecommitdiff
path: root/apps/web/app/reader/_components/entry-list.tsx
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-12 04:19:29 -0800
committerFuwn <[email protected]>2026-02-12 04:19:29 -0800
commit285cd8c3abe8fe9f4fe271c79cbe63f238e8e4cc (patch)
tree8a528bbe904ad766a7c973df544627f8e9edd29c /apps/web/app/reader/_components/entry-list.tsx
parentfix: prioritise unread entries server-side so they appear in all-entries view (diff)
downloadasa.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/web/app/reader/_components/entry-list.tsx')
-rw-r--r--apps/web/app/reader/_components/entry-list.tsx13
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 (