From 585ca55c27b700f42b07d9c33a0573a142bd46a8 Mon Sep 17 00:00:00 2001 From: Ez-Z Date: Thu, 13 Dec 2018 16:16:09 +0800 Subject: [PATCH] fix: reload menu open question MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit collapsed 为false时,刷新后菜单的openKeys为[]时,导致菜单不展开的问题 --- src/components/SiderMenu/BaseMenu.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/SiderMenu/BaseMenu.js b/src/components/SiderMenu/BaseMenu.js index 93e5094e..4448c5a5 100644 --- a/src/components/SiderMenu/BaseMenu.js +++ b/src/components/SiderMenu/BaseMenu.js @@ -126,6 +126,7 @@ export default class BaseMenu extends PureComponent { mode, location: { pathname }, className, + collapsed, } = this.props; // if pathname can't match, use the nearest parent's key let selectedKeys = this.getSelectedMenuKeys(pathname); @@ -133,9 +134,9 @@ export default class BaseMenu extends PureComponent { selectedKeys = [openKeys[openKeys.length - 1]]; } let props = {}; - if (openKeys) { + if (openKeys && !collapsed) { props = { - openKeys, + openKeys: openKeys.length === 0 ? [...selectedKeys] : openKeys, }; } const { handleOpenChange, style, menuData } = this.props; -- GitLab