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

Commit 98e4418

Browse files
fix(overflowmenu): bring over the rest of the IE11 fix (#63)
* 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
1 parent 803462a commit 98e4418

File tree

3 files changed

+32
-6
lines changed

3 files changed

+32
-6
lines changed

components/OverflowMenu.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ class OverflowMenu extends Component {
8282
};
8383

8484
handleClickOutside = () => {
85+
this.closeMenu();
86+
};
87+
88+
closeMenu = () => {
8589
this.setState({ open: false });
8690
};
8791

@@ -98,6 +102,7 @@ class OverflowMenu extends Component {
98102
menuOffset,
99103
menuOffsetFlip,
100104
iconClass,
105+
onClick, // eslint-disable-line
101106
...other
102107
} = this.props;
103108

@@ -119,12 +124,17 @@ class OverflowMenu extends Component {
119124
iconClass
120125
);
121126

127+
const childrenWithProps = React.Children.map(children, child =>
128+
React.cloneElement(child, {
129+
closeMenu: this.closeMenu,
130+
})
131+
);
132+
122133
return (
123134
<ClickListener onClickOutside={this.handleClickOutside}>
124135
<div
125136
{...other}
126137
className={overflowMenuClasses}
127-
onClick={this.handleClick}
128138
onKeyDown={this.handleKeyPress}
129139
aria-label={ariaLabel}
130140
id={id}
@@ -134,6 +144,7 @@ class OverflowMenu extends Component {
134144
}}
135145
>
136146
<Icon
147+
onClick={this.handleClick}
137148
className={overflowMenuIconClasses}
138149
name={iconName}
139150
description={iconDescription}
@@ -146,11 +157,11 @@ class OverflowMenu extends Component {
146157
menuOffset={flipped ? menuOffsetFlip : menuOffset}
147158
>
148159
<ul className={overflowMenuOptionsClasses}>
149-
{children}
160+
{childrenWithProps}
150161
</ul>
151162
</FloatingMenu>
152163
: <ul className={overflowMenuOptionsClasses}>
153-
{children}
164+
{childrenWithProps}
154165
</ul>}
155166
</div>
156167
</ClickListener>

components/OverflowMenuItem.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,22 @@ const propTypes = {
1616
onMouseEnter: PropTypes.func,
1717
onMouseLeave: PropTypes.func,
1818
onMouseUp: PropTypes.func,
19+
closeMenu: React.PropTypes.func,
1920
};
2021

2122
const defaultProps = {
2223
hasDivider: false,
2324
isDelete: false,
25+
onClick: () => {},
2426
};
2527

2628
const OverflowMenuItem = ({
2729
className,
2830
itemText,
2931
hasDivider,
3032
isDelete,
33+
closeMenu,
34+
onClick,
3135
...other
3236
}) => {
3337
const overflowMenuBtnClasses = classNames(
@@ -43,9 +47,19 @@ const OverflowMenuItem = ({
4347
}
4448
);
4549

50+
const handleClick = evt => {
51+
onClick(evt);
52+
closeMenu();
53+
};
54+
4655
const item = (
4756
<li className={overflowMenuItemClasses}>
48-
<button {...other} type="button" className={overflowMenuBtnClasses}>
57+
<button
58+
{...other}
59+
type="button"
60+
className={overflowMenuBtnClasses}
61+
onClick={handleClick}
62+
>
4963
{itemText}
5064
</button>
5165
</li>

components/__tests__/OverflowMenu-test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,12 @@ describe('OverflowMenu', () => {
8686
expect(menuOptions.hasClass(openClass)).not.toEqual(false);
8787
});
8888

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

93-
menu.simulate('click');
94+
icon.simulate('click');
9495
expect(rootWrapper.state().open).toEqual(true);
9596
});
9697

0 commit comments

Comments
 (0)