Fix inlineCollapsed menu when submenu is opened

close #7524

close #7514

ref #7063
This commit is contained in:
afc163 2017-09-09 00:58:15 +08:00
parent 2feef3358c
commit 35fc427630

View File

@ -99,20 +99,21 @@ export default class Menu extends React.Component<MenuProps, any> {
nextProps.mode !== 'inline') {
this.switchModeFromInline = true;
}
if ('openKeys' in nextProps) {
this.setState({ openKeys: nextProps.openKeys });
return;
}
if ((nextProps.inlineCollapsed && !this.props.inlineCollapsed) ||
(nextContext.siderCollapsed && !this.context.siderCollapsed)) {
this.switchModeFromInline = !!this.state.openKeys.length;
this.inlineOpenKeys = this.state.openKeys;
this.handleOpenChange([]);
this.setState({ openKeys: [] });
}
if ((!nextProps.inlineCollapsed && this.props.inlineCollapsed) ||
(!nextContext.siderCollapsed && this.context.siderCollapsed)) {
this.handleOpenChange(this.inlineOpenKeys);
this.setState({ openKeys: this.inlineOpenKeys });
this.inlineOpenKeys = [];
}
if ('openKeys' in nextProps) {
this.setState({ openKeys: nextProps.openKeys });
}
}
handleClick = (e) => {
this.handleOpenChange([]);