Skip to content

Commit

Permalink
Merge pull request #5843 from olee/master
Browse files Browse the repository at this point in the history
[IconMenu] Changed IconMenu to conditionally add button iconStyle
  • Loading branch information
oliviertassinari committed Dec 28, 2016
2 parents 4d5de14 + 69ad9fa commit 9363b3a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
13 changes: 8 additions & 5 deletions src/IconMenu/IconMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,19 +274,22 @@ class IconMenu extends Component {
`Material-UI: You shoud not provide an <SvgIcon /> to the 'iconButtonElement' property of <IconMenu />.
You should wrapped it with an <IconButton />.`);

const iconButton = React.cloneElement(iconButtonElement, {
const iconButtonProps = {
onKeyboardFocus: onKeyboardFocus,
iconStyle: iconStyle ?
Object.assign({}, iconStyle, iconButtonElement.props.iconStyle) :
iconButtonElement.props.iconStyle,
onTouchTap: (event) => {
this.open(Events.isKeyboard(event) ? 'keyboard' : 'iconTap', event);
if (iconButtonElement.props.onTouchTap) {
iconButtonElement.props.onTouchTap(event);
}
},
ref: 'iconButton',
});
};
if (iconStyle || iconButtonElement.props.iconStyle) {
iconButtonProps.iconStyle = iconStyle ?
Object.assign({}, iconStyle, iconButtonElement.props.iconStyle) :
iconButtonElement.props.iconStyle;
}
const iconButton = React.cloneElement(iconButtonElement, iconButtonProps);

const menu = (
<Menu
Expand Down
4 changes: 2 additions & 2 deletions src/IconMenu/IconMenu.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('<IconMenu />', function() {
<IconMenu iconButtonElement={<div data-test="my-icon-button" />} />
);

assert.strictEqual(wrapper.find('[data-test="my-icon-button"]').props().iconStyle,
undefined, 'should leak property on the div');
assert.strictEqual(wrapper.find('[data-test="my-icon-button"]').props().hasOwnProperty('iconStyle'), false,
'should leak property on the div');
});
});

0 comments on commit 9363b3a

Please sign in to comment.