Skip to content

Commit

Permalink
Merge pull request #6907 from harishsurf/accessibility_dropdown
Browse files Browse the repository at this point in the history
Bug 1874968: Pressing escape key doesn't exit the dropdown list
  • Loading branch information
openshift-merge-robot committed Dec 4, 2020
2 parents 12f6d06 + cb887e5 commit 3493431
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions frontend/public/components/utils/dropdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,13 @@ export class Dropdown extends DropdownMixin {
this.onKeyDown = (e) => this.onKeyDown_(e);
this.changeTextFilter = (e) => this.applyTextFilter_(e.target.value, this.props.items);
const { shortCut } = this.props;

this.globalKeyDown = (e) => {
if (e.key === 'Escape' && this.state.active) {
this.hide(e);
return;
}

const { nodeName } = e.target;

if (nodeName === 'INPUT' || nodeName === 'TEXTAREA') {
Expand Down Expand Up @@ -302,10 +308,6 @@ export class Dropdown extends DropdownMixin {

onKeyDown_(e) {
const { key } = e;
if (key === 'Escape') {
this.hide(e);
return;
}

if (key !== 'ArrowDown' && key !== 'ArrowUp' && key !== 'Enter') {
return;
Expand Down

0 comments on commit 3493431

Please sign in to comment.