diff --git a/client/src/components/Sidebar/SidebarContainer.js b/client/src/components/Sidebar/SidebarContainer.js index d8f4ab5c9..13b1b4a09 100644 --- a/client/src/components/Sidebar/SidebarContainer.js +++ b/client/src/components/Sidebar/SidebarContainer.js @@ -16,19 +16,42 @@ function SidebarContainer({ // #withDashboard sidebarExpended, }) { + const sidebarScrollerRef = React.useRef(); + useEffect(() => { document.body.classList.toggle('has-mini-sidebar', !sidebarExpended); + + if (!sidebarExpended && sidebarScrollerRef.current) { + sidebarScrollerRef.current.scrollTo({ + top: 0, + left: 0, + }); + } }, [sidebarExpended]); + const handleSidebarMouseLeave = () => { + if (!sidebarExpended && sidebarScrollerRef.current) { + sidebarScrollerRef.current.scrollTo({ top: 0, left: 0, }); + } + }; + + const scrollerElementRef = (ref) => { + sidebarScrollerRef.current = ref; + }; + return (