From 54678ba63ee1ce1540448414f342badfecec9b2d Mon Sep 17 00:00:00 2001 From: doudou <809539794@qq.com> Date: Fri, 1 Feb 2019 10:53:07 +0800 Subject: [PATCH] fixed submenu collapsed when refresh page (#3494) --- src/components/SiderMenu/SiderMenu.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/SiderMenu/SiderMenu.js b/src/components/SiderMenu/SiderMenu.js index 2522b4f0..b7782f7c 100644 --- a/src/components/SiderMenu/SiderMenu.js +++ b/src/components/SiderMenu/SiderMenu.js @@ -18,10 +18,14 @@ export default class SiderMenu extends PureComponent { } static getDerivedStateFromProps(props, state) { - const { pathname } = state; - if (props.location.pathname !== pathname) { + const { pathname, flatMenuKeysLen } = state; + if ( + props.location.pathname !== pathname || + props.flatMenuKeys.length !== flatMenuKeysLen + ) { return { pathname: props.location.pathname, + flatMenuKeysLen: props.flatMenuKeys.length, openKeys: getDefaultCollapsedSubMenus(props), }; } -- GitLab