Skip to content

Commit

Permalink
fix: recursion lose prefixCls (#737)
Browse files Browse the repository at this point in the history
  • Loading branch information
coding-ice authored Aug 15, 2024
1 parent f3a6f12 commit f3f03a2
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/utils/nodeUtil.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ function convertItemsToNodes(
// Group
return (
<MergedMenuItemGroup key={mergedKey} {...restProps} title={label}>
{convertItemsToNodes(children, components)}
{convertItemsToNodes(children, components, prefixCls)}
</MergedMenuItemGroup>
);
}

// Sub Menu
return (
<MergedSubMenu key={mergedKey} {...restProps} title={label}>
{convertItemsToNodes(children, components)}
{convertItemsToNodes(children, components, prefixCls)}
</MergedSubMenu>
);
}
Expand Down
22 changes: 22 additions & 0 deletions tests/MenuItem.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,5 +206,27 @@ describe('MenuItem', () => {

expect(container.querySelector('li')).toMatchSnapshot();
});

it('should set extra to group option', () => {
const { container } = render(
<Menu
items={[
{
type: 'group',
label: 'Top Menu Group with children',
children: [
{
label: 'Menu Item 1',
key: 'top',
extra: '⌘B',
},
],
},
]}
/>,
);

expect(container.querySelector('li')).toMatchSnapshot();
});
});
});
33 changes: 33 additions & 0 deletions tests/__snapshots__/MenuItem.spec.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,38 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`MenuItem overwrite default role should set extra to group option 1`] = `
<li
class="rc-menu-item-group"
role="presentation"
>
<div
class="rc-menu-item-group-title"
role="presentation"
title="Top Menu Group with children"
>
Top Menu Group with children
</div>
<ul
class="rc-menu-item-group-list"
role="group"
>
<li
class="rc-menu-item"
data-menu-id="rc-menu-uuid-test-top"
role="menuitem"
tabindex="-1"
>
Menu Item 1
<span
class="rc-menu-extra"
>
⌘B
</span>
</li>
</ul>
</li>
`;

exports[`MenuItem overwrite default role should set extra to option 1`] = `
<li
class="rc-menu-item"
Expand Down

0 comments on commit f3f03a2

Please sign in to comment.