From 77eac16e979168cc34d18efd540056e9512be7fa Mon Sep 17 00:00:00 2001 From: valleykid Date: Tue, 7 Nov 2017 12:11:27 +0800 Subject: [PATCH] Fixed issue#124 (#125) Fix submenu cannot open --- src/layouts/BasicLayout.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/layouts/BasicLayout.js b/src/layouts/BasicLayout.js index bdc823ce..9a0237bf 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 = () => { -- GitLab