diff --git a/src/renderer/src/components/AppShell.tsx b/src/renderer/src/components/AppShell.tsx index b8ad345..b525265 100644 --- a/src/renderer/src/components/AppShell.tsx +++ b/src/renderer/src/components/AppShell.tsx @@ -1,4 +1,4 @@ -import { Fragment, useEffect, useState } from "react"; +import { Fragment, useEffect, useLayoutEffect, useRef, useState } from "react"; import { ArrowLeft, ChevronLeft, @@ -140,6 +140,14 @@ function Shell() { ? `${nav.current.kind}:${nav.current.id}` : nav.current.kind; + const stageRef = useRef(null); + useLayoutEffect(() => { + const el = stageRef.current; + if (!el) return; + const saved = nav.getViewState(`scroll:${stageKey}`); + el.scrollTop = typeof saved === "number" ? saved : 0; + }, [stageKey, nav]); + return (
@@ -194,7 +202,11 @@ function Shell() {
-
+
nav.setViewState(`scroll:${stageKey}`, e.currentTarget.scrollTop)} + > {nav.canBack ? (