Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert partial changes in #233 (causing problems) #339

Merged
merged 3 commits into from
Sep 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/components/SiderMenu/SiderMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,11 @@ export default class SiderMenu extends PureComponent {
};

handleOpenChange = openKeys => {
const lastOpenKey = openKeys[openKeys.length - 1];
const moreThanOne =
openKeys.filter(openKey => this.isMainMenu(openKey)).length > 1;
this.setState({
openKeys: [...openKeys]
openKeys: moreThanOne ? [lastOpenKey] : [...openKeys]
});
};

Expand Down Expand Up @@ -310,6 +313,11 @@ export default class SiderMenu extends PureComponent {
const { menuData, collapsed, onCollapse, TitleLogo } = this.props;
const { openKeys } = this.state;
// Don't show popup menu when it is been collapsed
const menuProps = collapsed
? {}
: {
openKeys
};
// if pathname can't match, use the nearest parent's key
let selectedKeys = this.getSelectedMenuKeys();
if (!selectedKeys.length) {
Expand Down Expand Up @@ -341,6 +349,9 @@ export default class SiderMenu extends PureComponent {
key="Menu"
theme={this.state.theme}
mode={this.state.mode}
{...menuProps}
onOpenChange={this.handleOpenChange}
selectedKeys={selectedKeys}
style={{ padding: "16px 0", width: "100%" }}
>
{this.getNavMenuItems(menuData)}
Expand Down
Loading