Skip to content

Commit

Permalink
fix(OverflowMenu): avoid trapping focus on trigger button (#4688)
Browse files Browse the repository at this point in the history
  • Loading branch information
emyarod authored and asudoh committed Nov 19, 2019
1 parent 4fb1856 commit 7cd956b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/react/src/components/OverflowMenu/OverflowMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,13 +326,22 @@ class OverflowMenu extends Component {
};

handleKeyPress = evt => {
if (!keyCodeMatches(evt, [keys.Enter, keys.Space])) {
if (
this.state.open &&
keyCodeMatches(evt, [
keys.ArrowUp,
keys.ArrowRight,
keys.ArrowDown,
keys.ArrowLeft,
])
) {
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])) {
evt.preventDefault();
this.setState({ open: true });
}
}
Expand Down

0 comments on commit 7cd956b

Please sign in to comment.