Merge pull request #2035 from bluewave-labs/fix/fe/sidebar-menu-icons
Fix sidebar menu icons appearing before full expansion
This commit is contained in:
2 files changed
+31
-1
No files matched your search
@@ -79,6 +79,17 @@ aside .MuiListSubheader-root {
|
|||||||
transition: padding 200ms ease;
|
transition: padding 200ms ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sidebar-delay-fade {
|
||||||
|
opacity: 0;
|
||||||
|
visibility: hidden;
|
||||||
|
transition: opacity 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
aside.sidebar-ready .sidebar-delay-fade {
|
||||||
|
opacity: 1;
|
||||||
|
visibility: visible;
|
||||||
|
}
|
||||||
|
|
||||||
@keyframes fadeIn {
|
@keyframes fadeIn {
|
||||||
0% {
|
0% {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState, useRef } from "react";
|
||||||
import {
|
import {
|
||||||
Box,
|
Box,
|
||||||
Collapse,
|
Collapse,
|
||||||
@@ -127,6 +127,23 @@ function Sidebar() {
|
|||||||
const distributedUptimeEnabled = useSelector(
|
const distributedUptimeEnabled = useSelector(
|
||||||
(state) => state.ui.distributedUptimeEnabled
|
(state) => state.ui.distributedUptimeEnabled
|
||||||
);
|
);
|
||||||
|
const sidebarRef = useRef(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const el = sidebarRef.current;
|
||||||
|
if (!el) return;
|
||||||
|
|
||||||
|
const TRANSITION_DURATION = 200;
|
||||||
|
|
||||||
|
if (!collapsed) {
|
||||||
|
const timeout = setTimeout(() => {
|
||||||
|
el.classList.add("sidebar-ready");
|
||||||
|
}, TRANSITION_DURATION);
|
||||||
|
return () => clearTimeout(timeout);
|
||||||
|
} else {
|
||||||
|
el.classList.remove("sidebar-ready");
|
||||||
|
}
|
||||||
|
}, [collapsed]);
|
||||||
|
|
||||||
const renderAccountMenuItems = () => {
|
const renderAccountMenuItems = () => {
|
||||||
let filteredAccountMenuItems = [...accountMenuItems];
|
let filteredAccountMenuItems = [...accountMenuItems];
|
||||||
@@ -196,6 +213,7 @@ function Sidebar() {
|
|||||||
return (
|
return (
|
||||||
<Stack
|
<Stack
|
||||||
component="aside"
|
component="aside"
|
||||||
|
ref={sidebarRef}
|
||||||
className={collapsed ? "collapsed" : "expanded"}
|
className={collapsed ? "collapsed" : "expanded"}
|
||||||
/* TODO general padding should be here */
|
/* TODO general padding should be here */
|
||||||
py={theme.spacing(6)}
|
py={theme.spacing(6)}
|
||||||
@@ -725,6 +743,7 @@ function Sidebar() {
|
|||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
<Stack
|
<Stack
|
||||||
|
className="sidebar-delay-fade"
|
||||||
flexDirection={"row"}
|
flexDirection={"row"}
|
||||||
marginLeft={"auto"}
|
marginLeft={"auto"}
|
||||||
columnGap={theme.spacing(2)}
|
columnGap={theme.spacing(2)}
|
||||||
|
|||||||
Reference in new issue
Block a user