Skip to content

Commit

Permalink
Fixed bug with sidebar indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
shivankacker committed Sep 13, 2024
1 parent 8b678bf commit ad3d2b9
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Components/Common/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const StatelessSidebar = ({
const [lastIndicatorPosition, setLastIndicatorPosition] = useState(0);
const [isOverflowVisible, setOverflowVisisble] = useState(false);

useEffect(() => {
const updateIndicator = () => {
if (!indicatorRef.current) return;
const index = NavItems.findIndex((item) => item.to === activeLink);
const navItemCount = NavItems.length + (careConfig.urls.dashboard ? 2 : 1); // +2 for notification and dashboard
Expand All @@ -94,8 +94,17 @@ const StatelessSidebar = ({
} else {
indicatorRef.current.style.display = "none";
}
};

useEffect(() => {
updateIndicator();
}, [activeLink, lastIndicatorPosition]);

useEffect(() => {
window.addEventListener("resize", updateIndicator);
return () => window.removeEventListener("resize", updateIndicator);
}, []);

const handleOverflow = (value: boolean) => {
setOverflowVisisble(value);
};
Expand Down

0 comments on commit ad3d2b9

Please sign in to comment.