From 1a0cea28a331cbc86bac0fa874c4b7e3d44f9633 Mon Sep 17 00:00:00 2001 From: ycjcl868 <45808948@qq.com> Date: Thu, 27 Dec 2018 09:44:52 +0800 Subject: [PATCH] :bug: site menu open bug --- site/theme/template/Content/MainContent.jsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/site/theme/template/Content/MainContent.jsx b/site/theme/template/Content/MainContent.jsx index 6068bbad86..3c9baed7b2 100644 --- a/site/theme/template/Content/MainContent.jsx +++ b/site/theme/template/Content/MainContent.jsx @@ -70,10 +70,13 @@ export default class MainContent extends React.PureComponent { } static getDerivedStateFromProps(props, state) { - return { - ...state, - openKeys: getSideBarOpenKeys(props), - }; + if (!state.openKeys) { + return { + ...state, + openKeys: getSideBarOpenKeys(props), + }; + } + return null; } componentDidUpdate(prevProps) { @@ -259,7 +262,7 @@ export default class MainContent extends React.PureComponent { inlineIndent="40" className="aside-container menu-site" mode="inline" - defaultOpenKeys={openKeys} + openKeys={openKeys} selectedKeys={[activeMenuItem]} onOpenChange={this.handleMenuOpenChange} >