Skip to content

Commit 7570084

Browse files
committed
frontend: persist sidebar expanded state
The sidebar's expanded/collapsed state is now saved in `localStorage`. This ensures that if the user collapses the sidebar, it stays collapsed after reloading the page or returning to the app later. Implemented via a `useState` lazy initializer and `useEffect` hook in `App.jsx`.
1 parent 5ff5295 commit 7570084

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

frontend/src/App.jsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,14 @@ import LogViewer from './components/views/LogViewer'
3636

3737
function App() {
3838
const [view, setView] = useState('dashboard')
39-
const [sidebarExpanded, setSidebarExpanded] = useState(true)
39+
const [sidebarExpanded, setSidebarExpanded] = useState(() => {
40+
const saved = localStorage.getItem('sidebarExpanded')
41+
return saved !== null ? JSON.parse(saved) : true
42+
})
43+
44+
useEffect(() => {
45+
localStorage.setItem('sidebarExpanded', JSON.stringify(sidebarExpanded))
46+
}, [sidebarExpanded])
4047
const [autoloadStatus, setAutoloadStatus] = useState(null)
4148
const [logs, setLogs] = useState([])
4249
const [payloads, setPayloads] = useState([])

0 commit comments

Comments
 (0)