Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Menu): Group.Item cant pass custom className #5

Merged
merged 1 commit into from
Oct 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/menu/view/group.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ export default class Group extends Component {
[className]: !!className
});

const newChildClassName = cx({
[`${prefix}menu-group-item`]: true
});

const newChildren = children.map(child => {
const { className } = child.props;
const newChildClassName = cx({
[`${prefix}menu-group-item`]: true,
[className]: !!className
});

return cloneElement(child, {
parentMode,
className: newChildClassName
Expand Down
17 changes: 17 additions & 0 deletions test/menu/index-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,23 @@ describe('Menu', () => {
assert(item.find('.next-menu-item-helper').text() === 'helper');
});

it('should pass className', () => {
wrapper = mount(
<Menu defaultOpenKeys="sub-menu" className="custom" style={{ color: 'red' }}>
<Item className="custom-className">item</Item>
<Group label="Group">
<Item className="custom-className" key="group-1">Group option 1</Item>
</Group>
<SubMenu key="sub-menu" label="Sub menu">
<Item className="custom-className" key="sub-1">Sub option 1</Item>
</SubMenu>
</Menu>
);
const menu = wrapper.find('.next-menu li.custom-className');

assert(menu.length === 3);
});

it('should support onItemClick', () => {
let called = false, key, item, event;
const handleItemClick = (k, i, e) => {
Expand Down