mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-29 05:29:37 +08:00
Fix context change logic
This commit is contained in:
parent
89a37da77f
commit
82afb368c0
@ -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…
Reference in New Issue
Block a user