فهرست منبع

fixed submenu collapsed when refresh page (#3494)

doudou 7 سال پیش
والد
کامیت
54678ba63e
1فایلهای تغییر یافته به همراه6 افزوده شده و 2 حذف شده
  1. 6 2
      src/components/SiderMenu/SiderMenu.js

+ 6 - 2
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),
       };
     }