mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-18 22:36:31 +08:00
Fix openKeys is not working when mode is switched, close #4876
This commit is contained in:
parent
9fede4a5cd
commit
4cbcc05b02
@ -98,4 +98,21 @@ describe('Menu', () => {
|
||||
wrapper.update();
|
||||
// just expect no error emit
|
||||
});
|
||||
|
||||
it('should always follow openKeys when mode is switched', () => {
|
||||
const wrapper = mount(
|
||||
<Menu openKeys={['1']} mode="inline">
|
||||
<SubMenu key="1" title="submenu1">
|
||||
<Menu.Item key="submenu1">Option 1</Menu.Item>
|
||||
<Menu.Item key="submenu2">Option 2</Menu.Item>
|
||||
</SubMenu>
|
||||
<Menu.Item key="2">menu2</Menu.Item>
|
||||
</Menu>
|
||||
);
|
||||
expect(wrapper.find('.ant-menu-sub').at(0).hasClass('ant-menu-hidden')).not.toBe(true);
|
||||
wrapper.setProps({ mode: 'vertical' });
|
||||
expect(wrapper.find('.ant-menu-sub').at(0).hasClass('ant-menu-hidden')).not.toBe(true);
|
||||
wrapper.setProps({ mode: 'inline' });
|
||||
expect(wrapper.find('.ant-menu-sub').at(0).hasClass('ant-menu-hidden')).not.toBe(true);
|
||||
});
|
||||
});
|
||||
|
@ -88,7 +88,7 @@ export default class Menu extends React.Component<MenuProps, any> {
|
||||
this.switchModeFromInline = true;
|
||||
}
|
||||
if ('openKeys' in nextProps) {
|
||||
this.setOpenKeys(nextProps.openKeys);
|
||||
this.setState({ openKeys: nextProps.openKeys });
|
||||
}
|
||||
}
|
||||
handleClick = (e) => {
|
||||
|
Loading…
Reference in New Issue
Block a user