diff --git a/src/layouts/BasicLayout.js b/src/layouts/BasicLayout.js index bdc823cec36d9a5173130cac96dd9e72121d8002..9a0237bfcfd4a1878de191dda87a21b014b049e6 100644 --- a/src/layouts/BasicLayout.js +++ b/src/layouts/BasicLayout.js @@ -187,9 +187,12 @@ class BasicLayout extends React.PureComponent { return groupBy(newNotices, 'type'); } handleOpenChange = (openKeys) => { - const latestOpenKey = openKeys.find(key => this.state.openKeys.indexOf(key) === -1); + const lastOpenKey = openKeys[openKeys.length - 1]; + const isMainMenu = this.menus.some( + item => (item.key === lastOpenKey || item.path === lastOpenKey) + ); this.setState({ - openKeys: latestOpenKey ? [latestOpenKey] : [], + openKeys: isMainMenu ? [lastOpenKey] : [...openKeys], }); } toggle = () => {