Keep note list mounted off-screen on mobile to perfectly preserve scroll position
This commit is contained in:
1 parent
e1a861faea
commit
2f14f48ac1
1 file changed
+7
-6
@@ -578,15 +578,16 @@ export default function EvercloneWorkspace() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (mobilePane === 'list' && listParentRef.current) {
|
if (mobilePane === 'list' && listParentRef.current) {
|
||||||
const targetScroll = listScrollPosRef.current;
|
const targetScroll = listScrollPosRef.current;
|
||||||
// Also ensure window itself is at top (prevent browser auto-scroll offset)
|
|
||||||
if (typeof window !== 'undefined') {
|
if (typeof window !== 'undefined') {
|
||||||
window.scrollTo(0, 0);
|
window.scrollTo(0, 0);
|
||||||
}
|
}
|
||||||
requestAnimationFrame(() => {
|
// Use double rAF / timeout to ensure browser layout and virtualizer are completely settled
|
||||||
|
const timer = setTimeout(() => {
|
||||||
if (listParentRef.current) {
|
if (listParentRef.current) {
|
||||||
listParentRef.current.scrollTop = targetScroll;
|
listParentRef.current.scrollTop = targetScroll;
|
||||||
}
|
}
|
||||||
});
|
}, 30);
|
||||||
|
return () => clearTimeout(timer);
|
||||||
}
|
}
|
||||||
}, [mobilePane]);
|
}, [mobilePane]);
|
||||||
|
|
||||||
@@ -1479,9 +1480,9 @@ export default function EvercloneWorkspace() {
|
|||||||
<>
|
<>
|
||||||
{/* 2. MIDDLE NOTE LIST PANE */}
|
{/* 2. MIDDLE NOTE LIST PANE */}
|
||||||
<section
|
<section
|
||||||
className={`${
|
className={`w-full ${
|
||||||
mobilePane === 'editor' ? 'hidden md:flex' : 'flex'
|
mobilePane === 'editor' ? 'max-md:invisible max-md:absolute max-md:-left-[9999px] max-md:pointer-events-none' : 'flex'
|
||||||
} w-full ${
|
} ${
|
||||||
listMode === 'cards'
|
listMode === 'cards'
|
||||||
? 'md:w-96 lg:w-[460px] xl:w-[500px]'
|
? 'md:w-96 lg:w-[460px] xl:w-[500px]'
|
||||||
: 'md:w-80 lg:w-96'
|
: 'md:w-80 lg:w-96'
|
||||||
|
|||||||
Reference in new issue
Block a user