add sidebarReady state and update useffect

This commit is contained in:
Vishnu Sreekumaran Nair committed 2025-04-07 14:55:43 -04:00
1 parent 29245f2571
commit 79cabb770a
1 file changed
+5 -8
+5 -8
View File
@@ -128,20 +128,17 @@ function Sidebar() {
(state) => state.ui.distributedUptimeEnabled
);
const sidebarRef = useRef(null);
const [sidebarReady, setSidebarReady] = useState(!collapsed);
useEffect(() => {
const el = sidebarRef.current;
if (!el) return;
const TRANSITION_DURATION = 200;
if (!collapsed) {
setSidebarReady(false);
const timeout = setTimeout(() => {
el.classList.add("sidebar-ready");
}, TRANSITION_DURATION);
setSidebarReady(true);
}, 200);
return () => clearTimeout(timeout);
} else {
el.classList.remove("sidebar-ready");
setSidebarReady(false);
}
}, [collapsed]);