Browse Source

Fix context change logic

pull/6686/head
afc163 8 years ago
parent
commit
82afb368c0
  1. 8
      components/menu/index.tsx

8
components/menu/index.tsx

@ -94,17 +94,19 @@ export default class Menu extends React.Component<MenuProps, any> {
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 = [];
}

Loading…
Cancel
Save