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

Commit

Permalink
fix(overflowmenu): remove handleBlur for now (#62)
Browse files Browse the repository at this point in the history
* fix(overflowmenu): remove handleBlur for now

* fix(ie11): temporary remove test
  • Loading branch information
Chris Dhanaraj authored Jun 23, 2017
1 parent b2a5a55 commit 47aff76
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 24 deletions.
7 changes: 0 additions & 7 deletions components/OverflowMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,6 @@ class OverflowMenu extends Component {
this.setState({ open: false });
};

handleBlur = evt => {
if (!this.menuEl.contains(evt.relatedTarget)) {
this.setState({ open: false });
}
};

render() {
const {
id,
Expand Down Expand Up @@ -130,7 +124,6 @@ class OverflowMenu extends Component {
className={overflowMenuClasses}
onClick={this.handleClick}
onKeyDown={this.handleKeyPress}
onBlur={this.handleBlur}
aria-label={ariaLabel}
id={id}
tabIndex={tabIndex}
Expand Down
39 changes: 22 additions & 17 deletions components/__tests__/OverflowMenu-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ describe('OverflowMenu', () => {
describe('Renders as expected', () => {
const rootWrapper = shallow(
<OverflowMenu className="extra-class">
<div className="test-child"></div>
<div className="test-child"></div>
<div className="test-child" />
<div className="test-child" />
</OverflowMenu>
);
const menu = rootWrapper.childAt(0);
Expand Down Expand Up @@ -51,7 +51,9 @@ describe('OverflowMenu', () => {

it('should set ariaLabel if one is passed via props', () => {
rootWrapper.setProps({ ariaLabel: 'test label' });
expect(rootWrapper.childAt(0).props()['aria-label']).toEqual('test label');
expect(rootWrapper.childAt(0).props()['aria-label']).toEqual(
'test label'
);
});

it('should set id if one is passed via props', () => {
Expand All @@ -60,7 +62,9 @@ describe('OverflowMenu', () => {
});

it('should apply a tabindex to the menu', () => {
const defaultMenu = shallow(<OverflowMenu><div>Child</div></OverflowMenu>).childAt(0);
const defaultMenu = shallow(
<OverflowMenu><div>Child</div></OverflowMenu>
).childAt(0);
expect(defaultMenu.props().tabIndex).toBe(0);
});
});
Expand Down Expand Up @@ -98,27 +102,28 @@ describe('OverflowMenu', () => {

rootWrapper.setState({ open: true });


menu.simulate('keydown', { which: spaceKey });
expect(rootWrapper.state().open).toEqual(false);
menu.simulate('keydown', { which: enterKey });
expect(rootWrapper.state().open).toEqual(true);
});

it('should be hidden when it loses focus', () => {
const rootWrapper = mount(
<OverflowMenu className="extra-class">
<div className="test-child"></div>
<div className="test-child"></div>
</OverflowMenu>
);
const menu = rootWrapper.childAt(0);
// Removed until a better solution appears
//
// it('should be hidden when it loses focus', () => {
// const rootWrapper = mount(
// <OverflowMenu className="extra-class">
// <div className="test-child"></div>
// <div className="test-child"></div>
// </OverflowMenu>
// );
// const menu = rootWrapper.childAt(0);

rootWrapper.setState({ open: true });
// rootWrapper.setState({ open: true });

menu.simulate('blur');
expect(rootWrapper.state().open).toEqual(false);
});
// menu.simulate('blur');
// expect(rootWrapper.state().open).toEqual(false);
// });

it('should be in a closed state after handleOutsideClick() is invoked', () => {
const rootWrapper = shallow(<OverflowMenu />);
Expand Down

0 comments on commit 47aff76

Please sign in to comment.