From b5c5436fac5a561cfe23feac1aca6f1e88afd827 Mon Sep 17 00:00:00 2001 From: David Mosberger-Tang Date: Thu, 19 Dec 2024 09:49:55 -0700 Subject: [PATCH] fix: allow collapsing a SideNav menu when it is not active It should be possible to collapse a parent item regardless of whether or not it is the currently active item. Prior to this fix, clicking on a parent item's "fold" icon was ignored unless the item was the currently active one. With this fix, the parent node and its children will be collapsed, as expected. --- src/components/SideMenu/SideMenu.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/SideMenu/SideMenu.tsx b/src/components/SideMenu/SideMenu.tsx index cb206ba0..ee41880c 100644 --- a/src/components/SideMenu/SideMenu.tsx +++ b/src/components/SideMenu/SideMenu.tsx @@ -38,8 +38,12 @@ export class SideMenu extends React.Component<{ menu: MenuStore; className?: str } activate = (item: IMenuItem) => { - if (item && item.active && this.context.menuToggle) { - return item.expanded ? item.collapse() : item.expand(); + if (item && this.context.menuToggle) { + if (item.expanded) { + item.collapse(); + return; + } + if (item.active) item.expand(); } this.props.menu.activateAndScroll(item, true); setTimeout(() => {