Skip to content

Commit

Permalink
fix(OverflowMenu): add stopPropagation call to handleClick method (#9816
Browse files Browse the repository at this point in the history
)
  • Loading branch information
rzhekova authored Oct 7, 2021
1 parent 2612bbd commit c53e708
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,15 @@ describe('OverflowMenu', () => {
);
});

it('fires onClick only once per button click', () => {
const mockOnClick = jest.fn();
const rootWrapper = mount(<OverflowMenu onClick={mockOnClick} />);

rootWrapper.find('button').simulate('click');

expect(mockOnClick).toHaveBeenCalledTimes(1);
});

it('should NOT toggle state in response to Enter or Space when the menu is open', () => {
const enterKey = 13;
const spaceKey = 32;
Expand Down
1 change: 1 addition & 0 deletions packages/react/src/components/OverflowMenu/OverflowMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ class OverflowMenu extends Component {
}

handleClick = (evt) => {
evt.stopPropagation();
if (!this._menuBody || !this._menuBody.contains(evt.target)) {
this.setState({ open: !this.state.open });
this.props.onClick(evt);
Expand Down

0 comments on commit c53e708

Please sign in to comment.