Skip to content

Commit

Permalink
Merge pull request #5 from youluna/fix/menu
Browse files Browse the repository at this point in the history
fix(Menu): Group.Item cant pass custom className
  • Loading branch information
frankqian authored Oct 17, 2018
2 parents 1de9e19 + eaf2570 commit 70ef562
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
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

0 comments on commit 70ef562

Please sign in to comment.