Merge pull request #2041 from bluewave-labs/fix/sidebar-icon-visibility
Fix sidebar icons visibility when toggling
This commit is contained in:
2 files changed
+8
-9
No files matched your search
@@ -85,7 +85,7 @@ aside .MuiListSubheader-root {
|
|||||||
transition: opacity 0.3s ease;
|
transition: opacity 0.3s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
aside.sidebar-ready .sidebar-delay-fade {
|
aside.expanded.sidebar-ready .sidebar-delay-fade {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
visibility: visible;
|
visibility: visible;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -128,20 +128,18 @@ function Sidebar() {
|
|||||||
(state) => state.ui.distributedUptimeEnabled
|
(state) => state.ui.distributedUptimeEnabled
|
||||||
);
|
);
|
||||||
const sidebarRef = useRef(null);
|
const sidebarRef = useRef(null);
|
||||||
|
const [sidebarReady, setSidebarReady] = useState(false);
|
||||||
|
const TRANSITION_DURATION = 200;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const el = sidebarRef.current;
|
|
||||||
if (!el) return;
|
|
||||||
|
|
||||||
const TRANSITION_DURATION = 200;
|
|
||||||
|
|
||||||
if (!collapsed) {
|
if (!collapsed) {
|
||||||
|
setSidebarReady(false);
|
||||||
const timeout = setTimeout(() => {
|
const timeout = setTimeout(() => {
|
||||||
el.classList.add("sidebar-ready");
|
setSidebarReady(true);
|
||||||
}, TRANSITION_DURATION);
|
}, TRANSITION_DURATION);
|
||||||
return () => clearTimeout(timeout);
|
return () => clearTimeout(timeout);
|
||||||
} else {
|
} else {
|
||||||
el.classList.remove("sidebar-ready");
|
setSidebarReady(false);
|
||||||
}
|
}
|
||||||
}, [collapsed]);
|
}, [collapsed]);
|
||||||
|
|
||||||
@@ -208,13 +206,14 @@ function Sidebar() {
|
|||||||
}, [location]);
|
}, [location]);
|
||||||
|
|
||||||
const iconColor = theme.palette.primary.contrastTextTertiary;
|
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 */
|
/* TODO refactor this, there are a some ternaries and comments in the return */
|
||||||
return (
|
return (
|
||||||
<Stack
|
<Stack
|
||||||
component="aside"
|
component="aside"
|
||||||
ref={sidebarRef}
|
ref={sidebarRef}
|
||||||
className={collapsed ? "collapsed" : "expanded"}
|
className={sidebarClassName}
|
||||||
/* TODO general padding should be here */
|
/* TODO general padding should be here */
|
||||||
py={theme.spacing(6)}
|
py={theme.spacing(6)}
|
||||||
gap={theme.spacing(6)}
|
gap={theme.spacing(6)}
|
||||||
|
|||||||
Reference in new issue
Block a user