Skip to content

Commit

Permalink
ComboboxControl: refactor onKeyDown to use keyboardEvent.code (#4…
Browse files Browse the repository at this point in the history
…2569)

* ComboboxControl: refactor `onKeyDown` to use `event.code`

* ComboboxControl: update Changelog
  • Loading branch information
chad1008 authored Jul 21, 2022
1 parent b346cd4 commit 6603931
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
- `BoxControl`: Refactor away from `_.isEmpty()` ([#42468](https://github.com/WordPress/gutenberg/pull/42468)).
- `RadioControl`: Refactor away from `_.isEmpty()` ([#42468](https://github.com/WordPress/gutenberg/pull/42468)).
- `SelectControl`: Refactor away from `_.isEmpty()` ([#42468](https://github.com/WordPress/gutenberg/pull/42468)).
- `ComboboxControl`: Replace `keyboardEvent.keyCode` with `keyboardEvent.code`([#42569](https://github.com/WordPress/gutenberg/pull/42569)).

## 19.15.0 (2022-07-13)

Expand Down
11 changes: 5 additions & 6 deletions packages/components/src/combobox-control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
useEffect,
} from '@wordpress/element';
import { useInstanceId } from '@wordpress/compose';
import { ENTER, UP, DOWN, ESCAPE } from '@wordpress/keycodes';
import { speak } from '@wordpress/a11y';
import { closeSmall } from '@wordpress/icons';

Expand Down Expand Up @@ -119,22 +118,22 @@ function ComboboxControl( {
return;
}

switch ( event.keyCode ) {
case ENTER:
switch ( event.code ) {
case 'Enter':
if ( selectedSuggestion ) {
onSuggestionSelected( selectedSuggestion );
preventDefault = true;
}
break;
case UP:
case 'ArrowUp':
handleArrowNavigation( -1 );
preventDefault = true;
break;
case DOWN:
case 'ArrowDown':
handleArrowNavigation( 1 );
preventDefault = true;
break;
case ESCAPE:
case 'Escape':
setIsExpanded( false );
setSelectedSuggestion( null );
preventDefault = true;
Expand Down

0 comments on commit 6603931

Please sign in to comment.