From 82afb368c0ca4cdbe2782d1fa19f7b20af5b8371 Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 30 Jun 2017 22:00:04 +0800 Subject: [PATCH] Fix context change logic --- components/menu/index.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/components/menu/index.tsx b/components/menu/index.tsx index 1e72c176fc..48fb373aef 100644 --- a/components/menu/index.tsx +++ b/components/menu/index.tsx @@ -94,17 +94,19 @@ export default class Menu extends React.Component { inlineCollapsed: this.getInlineCollapsed(), }; } - componentWillReceiveProps(nextProps) { + componentWillReceiveProps(nextProps, nextContext) { if (this.props.mode === 'inline' && nextProps.mode !== 'inline') { this.switchModeFromInline = true; } - if (nextProps.inlineCollapsed && !this.props.inlineCollapsed) { + if ((nextProps.inlineCollapsed && !this.props.inlineCollapsed) || + (nextContext.siderCollapsed && !this.context.siderCollapsed)) { this.switchModeFromInline = true; this.inlineOpenKeys = this.state.openKeys; this.setOpenKeys([]); } - if (!nextProps.inlineCollapsed && this.props.inlineCollapsed) { + if ((!nextProps.inlineCollapsed && this.props.inlineCollapsed) || + (!nextContext.siderCollapsed && this.context.siderCollapsed)) { this.setOpenKeys(this.inlineOpenKeys); this.inlineOpenKeys = []; }