diff --git a/src/components/SiderMenu/SiderMenu.js b/src/components/SiderMenu/SiderMenu.js index df3bb488d99b923e35284b1336d87e4e934245ba..072f5cea9eb4326ea3e0dafd0abde9c18a3311b2 100644 --- a/src/components/SiderMenu/SiderMenu.js +++ b/src/components/SiderMenu/SiderMenu.js @@ -177,14 +177,17 @@ export default class SiderMenu extends PureComponent { } return ItemDom; }; - handleOpenChange = (openKeys) => { - const lastOpenKey = openKeys[openKeys.length - 1]; - const isMainMenu = this.menus.some( + isMainMenu = (key) => { + return this.menus.some( item => - lastOpenKey && (item.key === lastOpenKey || item.path === lastOpenKey), + key && (item.key === key || item.path === key), ); + } + handleOpenChange = (openKeys) => { + const lastOpenKey = openKeys[openKeys.length - 1]; + const moreThanOne = openKeys.filter(openKey => this.isMainMenu(openKey)).length > 1; this.setState({ - openKeys: isMainMenu ? [lastOpenKey] : [...openKeys], + openKeys: moreThanOne ? [lastOpenKey] : [...openKeys], }); }; render() {