Skip to content

Commit f3f03a2

Browse files
authored
fix: recursion lose prefixCls (#737)
1 parent f3a6f12 commit f3f03a2

File tree

3 files changed

+57
-2
lines changed

3 files changed

+57
-2
lines changed

src/utils/nodeUtil.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ function convertItemsToNodes(
3030
// Group
3131
return (
3232
<MergedMenuItemGroup key={mergedKey} {...restProps} title={label}>
33-
{convertItemsToNodes(children, components)}
33+
{convertItemsToNodes(children, components, prefixCls)}
3434
</MergedMenuItemGroup>
3535
);
3636
}
3737

3838
// Sub Menu
3939
return (
4040
<MergedSubMenu key={mergedKey} {...restProps} title={label}>
41-
{convertItemsToNodes(children, components)}
41+
{convertItemsToNodes(children, components, prefixCls)}
4242
</MergedSubMenu>
4343
);
4444
}

tests/MenuItem.spec.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,5 +206,27 @@ describe('MenuItem', () => {
206206

207207
expect(container.querySelector('li')).toMatchSnapshot();
208208
});
209+
210+
it('should set extra to group option', () => {
211+
const { container } = render(
212+
<Menu
213+
items={[
214+
{
215+
type: 'group',
216+
label: 'Top Menu Group with children',
217+
children: [
218+
{
219+
label: 'Menu Item 1',
220+
key: 'top',
221+
extra: '⌘B',
222+
},
223+
],
224+
},
225+
]}
226+
/>,
227+
);
228+
229+
expect(container.querySelector('li')).toMatchSnapshot();
230+
});
209231
});
210232
});

tests/__snapshots__/MenuItem.spec.tsx.snap

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,38 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`MenuItem overwrite default role should set extra to group option 1`] = `
4+
<li
5+
class="rc-menu-item-group"
6+
role="presentation"
7+
>
8+
<div
9+
class="rc-menu-item-group-title"
10+
role="presentation"
11+
title="Top Menu Group with children"
12+
>
13+
Top Menu Group with children
14+
</div>
15+
<ul
16+
class="rc-menu-item-group-list"
17+
role="group"
18+
>
19+
<li
20+
class="rc-menu-item"
21+
data-menu-id="rc-menu-uuid-test-top"
22+
role="menuitem"
23+
tabindex="-1"
24+
>
25+
Menu Item 1
26+
<span
27+
class="rc-menu-extra"
28+
>
29+
⌘B
30+
</span>
31+
</li>
32+
</ul>
33+
</li>
34+
`;
35+
336
exports[`MenuItem overwrite default role should set extra to option 1`] = `
437
<li
538
class="rc-menu-item"

0 commit comments

Comments
 (0)