diff --git a/src/Components/Sidebar/index.css b/src/Components/Sidebar/index.css index 3dac59aba..ef921acca 100644 --- a/src/Components/Sidebar/index.css +++ b/src/Components/Sidebar/index.css @@ -85,7 +85,7 @@ aside .MuiListSubheader-root { transition: opacity 0.3s ease; } -aside.sidebar-ready .sidebar-delay-fade { +aside.expanded.sidebar-ready .sidebar-delay-fade { opacity: 1; visibility: visible; } diff --git a/src/Components/Sidebar/index.jsx b/src/Components/Sidebar/index.jsx index 0ec9b9a2a..8d65acdde 100644 --- a/src/Components/Sidebar/index.jsx +++ b/src/Components/Sidebar/index.jsx @@ -128,20 +128,18 @@ function Sidebar() { (state) => state.ui.distributedUptimeEnabled ); const sidebarRef = useRef(null); + const [sidebarReady, setSidebarReady] = useState(false); + const TRANSITION_DURATION = 200; useEffect(() => { - const el = sidebarRef.current; - if (!el) return; - - const TRANSITION_DURATION = 200; - if (!collapsed) { + setSidebarReady(false); const timeout = setTimeout(() => { - el.classList.add("sidebar-ready"); + setSidebarReady(true); }, TRANSITION_DURATION); return () => clearTimeout(timeout); } else { - el.classList.remove("sidebar-ready"); + setSidebarReady(false); } }, [collapsed]); @@ -208,13 +206,14 @@ function Sidebar() { }, [location]); const iconColor = theme.palette.primary.contrastTextTertiary; + const sidebarClassName = `${collapsed ? "collapsed" : "expanded"} ${sidebarReady ? "sidebar-ready" : ""}`; /* TODO refactor this, there are a some ternaries and comments in the return */ return (