diff --git a/src/Menu.tsx b/src/Menu.tsx index fcee4bdf..4160daf0 100644 --- a/src/Menu.tsx +++ b/src/Menu.tsx @@ -141,7 +141,7 @@ class Menu extends React.Component { } if ('openKeys' in nextProps) { - newStoreState.openKeys = nextProps.openKeys; + newStoreState.openKeys = nextProps.openKeys || []; } else { // [Legacy] Old code will return after `openKeys` changed. // Not sure the reason, we should keep this logic still. diff --git a/tests/Menu.spec.js b/tests/Menu.spec.js index 2f4d1961..ad61b53c 100644 --- a/tests/Menu.spec.js +++ b/tests/Menu.spec.js @@ -247,6 +247,27 @@ describe('Menu', () => { ).not.toContain('-hidden'); }); + it('openKeys should allow to be empty', () => { + const wrapper = mount( + {}} + onOpenChange={() => {}} + openKeys={undefined} + selectedKeys={['1']} + mode="inline" + > + + + + 123123 + + + + , + ); + expect(wrapper).toBeTruthy(); + }); + it('open default submenu', () => { const wrapper = mount(