Skip to content

Commit 75b20ce

Browse files
committed
frontend: scroll to top of main content container on view change
1 parent 7dee294 commit 75b20ce

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

frontend/src/App.jsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState, useEffect } from 'react'
1+
import React, { useState, useEffect, useRef } from 'react'
22
import {
33
Settings,
44
CloudDownload,
@@ -36,6 +36,15 @@ import LogViewer from './components/views/LogViewer'
3636

3737
function App() {
3838
const [view, setView] = useState('dashboard')
39+
const mainRef = useRef(null)
40+
41+
useEffect(() => {
42+
if (mainRef.current) {
43+
mainRef.current.scrollTop = 0
44+
}
45+
window.scrollTo(0, 0)
46+
}, [view])
47+
3948
const [sidebarExpanded, setSidebarExpanded] = useState(() => {
4049
const saved = localStorage.getItem('sidebarExpanded')
4150
return saved !== null ? JSON.parse(saved) : true
@@ -457,7 +466,7 @@ function App() {
457466
"flex flex-col relative",
458467
isPS5 ? "h-screen flex-1 min-h-0" : "md:h-screen md:flex-1 md:min-h-0"
459468
)}>
460-
<main className={cn(
469+
<main ref={mainRef} className={cn(
461470
"custom-scrollbar max-w-[1800px] mx-auto w-full flex flex-col",
462471
isPS5 ? "pt-16 px-16 pb-12 flex-1 overflow-y-auto" : "pt-6 px-6 pb-36 md:pt-16 md:px-16 md:pb-12 md:flex-1 md:overflow-y-auto"
463472
)}>

0 commit comments

Comments
 (0)