diff --git a/src/components/SiderMenu/BaseMenu.js b/src/components/SiderMenu/BaseMenu.js index 93e5094eda211acb5643daa75e3ad3ec28608d00..4448c5a5315e178ce6efc873f0336bf357c853fa 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;