Skip to content
This repository has been archived by the owner on Oct 19, 2021. It is now read-only.

Commit

Permalink
fix(overflowmenu): bring over the rest of the IE11 fix (#63)
Browse files Browse the repository at this point in the history
* fix(overflowmenu): remove handleBlur for now

* fix(ie11): temporary remove test

* fix(ie11): port over full ie11 fix for overflowmenu

* fix(tests): update tests to reflect that icon is the new click target
  • Loading branch information
chrisdhanaraj authored Jul 12, 2017
1 parent 803462a commit 98e4418
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
17 changes: 14 additions & 3 deletions components/OverflowMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ class OverflowMenu extends Component {
};

handleClickOutside = () => {
this.closeMenu();
};

closeMenu = () => {
this.setState({ open: false });
};

Expand All @@ -98,6 +102,7 @@ class OverflowMenu extends Component {
menuOffset,
menuOffsetFlip,
iconClass,
onClick, // eslint-disable-line
...other
} = this.props;

Expand All @@ -119,12 +124,17 @@ class OverflowMenu extends Component {
iconClass
);

const childrenWithProps = React.Children.map(children, child =>
React.cloneElement(child, {
closeMenu: this.closeMenu,
})
);

return (
<ClickListener onClickOutside={this.handleClickOutside}>
<div
{...other}
className={overflowMenuClasses}
onClick={this.handleClick}
onKeyDown={this.handleKeyPress}
aria-label={ariaLabel}
id={id}
Expand All @@ -134,6 +144,7 @@ class OverflowMenu extends Component {
}}
>
<Icon
onClick={this.handleClick}
className={overflowMenuIconClasses}
name={iconName}
description={iconDescription}
Expand All @@ -146,11 +157,11 @@ class OverflowMenu extends Component {
menuOffset={flipped ? menuOffsetFlip : menuOffset}
>
<ul className={overflowMenuOptionsClasses}>
{children}
{childrenWithProps}
</ul>
</FloatingMenu>
: <ul className={overflowMenuOptionsClasses}>
{children}
{childrenWithProps}
</ul>}
</div>
</ClickListener>
Expand Down
16 changes: 15 additions & 1 deletion components/OverflowMenuItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,22 @@ const propTypes = {
onMouseEnter: PropTypes.func,
onMouseLeave: PropTypes.func,
onMouseUp: PropTypes.func,
closeMenu: React.PropTypes.func,
};

const defaultProps = {
hasDivider: false,
isDelete: false,
onClick: () => {},
};

const OverflowMenuItem = ({
className,
itemText,
hasDivider,
isDelete,
closeMenu,
onClick,
...other
}) => {
const overflowMenuBtnClasses = classNames(
Expand All @@ -43,9 +47,19 @@ const OverflowMenuItem = ({
}
);

const handleClick = evt => {
onClick(evt);
closeMenu();
};

const item = (
<li className={overflowMenuItemClasses}>
<button {...other} type="button" className={overflowMenuBtnClasses}>
<button
{...other}
type="button"
className={overflowMenuBtnClasses}
onClick={handleClick}
>
{itemText}
</button>
</li>
Expand Down
5 changes: 3 additions & 2 deletions components/__tests__/OverflowMenu-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,12 @@ describe('OverflowMenu', () => {
expect(menuOptions.hasClass(openClass)).not.toEqual(false);
});

it('should be in an open state after menu is clicked', () => {
it('should be in an open state after icon is clicked', () => {
const rootWrapper = mount(<OverflowMenu />);
const menu = rootWrapper.childAt(0);
const icon = menu.find(Icon);

menu.simulate('click');
icon.simulate('click');
expect(rootWrapper.state().open).toEqual(true);
});

Expand Down

1 comment on commit 98e4418

@chrisdhanaraj
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bluemix toolchain: Delivery Pipeline deployed carbon-components-react to Bluemix Design System, including this commit

Please sign in to comment.