Skip to content

Commit c53e708

Browse files
authored
fix(OverflowMenu): add stopPropagation call to handleClick method (#9816)
1 parent 2612bbd commit c53e708

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

packages/react/src/components/OverflowMenu/OverflowMenu-test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,15 @@ describe('OverflowMenu', () => {
160160
);
161161
});
162162

163+
it('fires onClick only once per button click', () => {
164+
const mockOnClick = jest.fn();
165+
const rootWrapper = mount(<OverflowMenu onClick={mockOnClick} />);
166+
167+
rootWrapper.find('button').simulate('click');
168+
169+
expect(mockOnClick).toHaveBeenCalledTimes(1);
170+
});
171+
163172
it('should NOT toggle state in response to Enter or Space when the menu is open', () => {
164173
const enterKey = 13;
165174
const spaceKey = 32;

packages/react/src/components/OverflowMenu/OverflowMenu.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ class OverflowMenu extends Component {
278278
}
279279

280280
handleClick = (evt) => {
281+
evt.stopPropagation();
281282
if (!this._menuBody || !this._menuBody.contains(evt.target)) {
282283
this.setState({ open: !this.state.open });
283284
this.props.onClick(evt);

0 commit comments

Comments
 (0)