summaryrefslogtreecommitdiffhomepage
path: root/gui/src/renderer/components
diff options
context:
space:
mode:
Diffstat (limited to 'gui/src/renderer/components')
-rw-r--r--gui/src/renderer/components/NavigationBar.tsx14
1 files changed, 13 insertions, 1 deletions
diff --git a/gui/src/renderer/components/NavigationBar.tsx b/gui/src/renderer/components/NavigationBar.tsx
index 02de9fdb6e..7e231646ce 100644
--- a/gui/src/renderer/components/NavigationBar.tsx
+++ b/gui/src/renderer/components/NavigationBar.tsx
@@ -123,7 +123,19 @@ export const NavigationScrollbars = React.forwardRef(function NavigationScrollba
const { addScrollPosition, removeScrollPosition } = useActions(userInterface);
const scrollPositions = useSelector((state) => state.userInterface.scrollPosition);
- useEffect(() => setScrollPositions(scrollPositions), [scrollPositions]);
+ useEffect(() => {
+ const path = history.location.pathname;
+ const beforeunload = () => {
+ if (ref.current) {
+ const scrollPosition = ref.current.getScrollPosition();
+ setScrollPositions({ ...scrollPositions, [path]: scrollPosition });
+ }
+ };
+
+ window.addEventListener('beforeunload', beforeunload);
+
+ return () => window.removeEventListener('beforeunload', beforeunload);
+ }, [scrollPositions]);
useLayoutEffect(() => {
const path = history.location.pathname;