Skip to content

Commit

Permalink
fix(OverflowMenu): prevent page scroll on menu navigation and selecti…
Browse files Browse the repository at this point in the history
…on (#4336)
  • Loading branch information
emyarod authored and abbeyhrt committed Oct 22, 2019
1 parent 427a7dd commit 700f21d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/react/src/components/OverflowMenu/OverflowMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,10 @@ class OverflowMenu extends Component {
};

handleKeyPress = evt => {
if (!keyCodeMatches(evt, [keys.Enter, keys.Space])) {
evt.preventDefault();
}

// only respond to key events when the menu is closed, so that menu items still respond to key events
if (!this.state.open) {
if (keyCodeMatches(evt, [keys.Enter, keys.Space])) {
Expand All @@ -331,7 +335,6 @@ class OverflowMenu extends Component {
this.closeMenu();
// Stop the esc keypress from bubbling out and closing something it shouldn't
evt.stopPropagation();
evt.preventDefault();
}
};

Expand Down

0 comments on commit 700f21d

Please sign in to comment.