Skip to content

Commit 4584dc1

Browse files
authored
fix: openKeys should allow to be empty (#360)
1 parent f65d352 commit 4584dc1

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/Menu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ class Menu extends React.Component<MenuProps, MenuState> {
141141
}
142142

143143
if ('openKeys' in nextProps) {
144-
newStoreState.openKeys = nextProps.openKeys;
144+
newStoreState.openKeys = nextProps.openKeys || [];
145145
} else {
146146
// [Legacy] Old code will return after `openKeys` changed.
147147
// Not sure the reason, we should keep this logic still.

tests/Menu.spec.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,27 @@ describe('Menu', () => {
247247
).not.toContain('-hidden');
248248
});
249249

250+
it('openKeys should allow to be empty', () => {
251+
const wrapper = mount(
252+
<Menu
253+
onClick={() => {}}
254+
onOpenChange={() => {}}
255+
openKeys={undefined}
256+
selectedKeys={['1']}
257+
mode="inline"
258+
>
259+
<SubMenu title="1231">
260+
<MenuItem>
261+
<a>
262+
<span>123123</span>
263+
</a>
264+
</MenuItem>
265+
</SubMenu>
266+
</Menu>,
267+
);
268+
expect(wrapper).toBeTruthy();
269+
});
270+
250271
it('open default submenu', () => {
251272
const wrapper = mount(
252273
<Menu defaultOpenKeys={['g1']}>

0 commit comments

Comments
 (0)