gui fixes
This commit is contained in:
parent
3bf89fe2fa
commit
b3e87772ec
4 changed files with 81 additions and 338 deletions
|
|
@ -1,7 +1,7 @@
|
|||
// File Path: web/frontend/src/components/Layout/Layout.jsx
|
||||
// Fixed Layout Component - Mobile Menu Now Works Properly
|
||||
|
||||
import React, { useState, useEffect, useCallback } from "react";
|
||||
import React, { useState, useEffect, useCallback, useRef } from "react";
|
||||
import TopNavbar from "./TopNavbar";
|
||||
import Sidebar from "./Sidebar";
|
||||
import { useInactivityTimeout } from "../../hooks/useInactivityTimeout";
|
||||
|
|
@ -292,7 +292,16 @@ function Layout({ children }) {
|
|||
return () => window.removeEventListener("resize", handleResize);
|
||||
}, [isMobile]); // Include isMobile but use functional state updates to avoid loops
|
||||
|
||||
// Track last toggle time to prevent double-clicks
|
||||
const lastToggleRef = useRef(0);
|
||||
|
||||
const handleMenuToggle = useCallback(() => {
|
||||
const now = Date.now();
|
||||
// Prevent double-clicks only (100ms window)
|
||||
if (now - lastToggleRef.current < 100) {
|
||||
return;
|
||||
}
|
||||
lastToggleRef.current = now;
|
||||
setIsSidebarOpen(current => !current);
|
||||
}, []);
|
||||
|
||||
|
|
@ -300,8 +309,17 @@ function Layout({ children }) {
|
|||
setIsSidebarOpen(false);
|
||||
}, []);
|
||||
|
||||
// Track last collapse toggle time to prevent double-clicks
|
||||
const lastCollapseToggleRef = useRef(0);
|
||||
|
||||
// Handle collapse toggle for desktop view
|
||||
const handleCollapseToggle = useCallback(() => {
|
||||
const now = Date.now();
|
||||
// Prevent double-clicks only (100ms window)
|
||||
if (now - lastCollapseToggleRef.current < 100) {
|
||||
return;
|
||||
}
|
||||
lastCollapseToggleRef.current = now;
|
||||
setSidebarCollapsed(current => {
|
||||
const newCollapsedState = !current;
|
||||
localStorage.setItem("sidebarCollapsed", newCollapsedState.toString());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue