File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ;
Original file line number Diff line number Diff 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 ) ;
You can’t perform that action at this time.
0 commit comments