diff --git a/frontend/src/components/Sidebar/Sidebar.tsx b/frontend/src/components/Sidebar/Sidebar.tsx index 532721eb2e..ec9e2bb0f0 100644 --- a/frontend/src/components/Sidebar/Sidebar.tsx +++ b/frontend/src/components/Sidebar/Sidebar.tsx @@ -248,6 +248,9 @@ export const PureSidebar = memo( linkArea, }: PureSidebarProps) => { const { t } = useTranslation(); + const listContainerRef = React.useRef(null); + const [isOverflowing, setIsOverflowing] = React.useState(false); + const adjustedDrawerWidthClosed = isOverflowing ? 84 : 72; const temporarySideBarOpen = open === true && isTemporaryDrawer && openUserSelected === true; // The large sidebar does not open in medium view (600-960px). @@ -276,6 +279,7 @@ export const PureSidebar = memo( })} /> { + const el = listContainerRef.current; + if (!el) { + return; + } + + const observer = new ResizeObserver(() => { + setIsOverflowing(el.scrollHeight > el.clientHeight); + }); + + observer.observe(el); + + setIsOverflowing(el.scrollHeight > el.clientHeight); + + return () => observer.disconnect(); + }, [items]); + return (