Skip to content

Commit

Permalink
fix: allow collapsing a SideNav menu when it is not active
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dmosberger committed Dec 19, 2024
1 parent 2d461f4 commit b5c5436
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/components/SideMenu/SideMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down

0 comments on commit b5c5436

Please sign in to comment.