Skip to content

Commit

Permalink
Fix context change logic
Browse files Browse the repository at this point in the history
  • Loading branch information
afc163 committed Jun 30, 2017
1 parent 89a37da commit 82afb36
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions components/menu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
}
Expand Down

0 comments on commit 82afb36

Please sign in to comment.