feat: scroll to top on list tab switch

This commit is contained in:
codytseng
2025-01-25 22:45:33 +08:00
parent 92b78d4573
commit acc47bad3d

View File

@@ -60,6 +60,7 @@ export default function NoteList({
...filter
}
}, [JSON.stringify(filter), isPictures])
const topRef = useRef<HTMLDivElement | null>(null)
useEffect(() => {
if (relayUrls.length === 0) return
@@ -174,14 +175,16 @@ export default function NoteList({
}
return (
<div className={cn('space-y-2 sm:space-y-2', className)}>
<div className={className}>
<ListModeSwitch
listMode={listMode}
setListMode={(listMode) => {
setListMode(listMode)
topRef.current?.scrollIntoView({ behavior: 'instant', block: 'end' })
storage.setNoteListMode(listMode)
}}
/>
<div ref={topRef} />
<PullToRefresh
onRefresh={async () => {
setRefreshCount((count) => count + 1)