From 49765aadafa8865bcc372a4d2abf350d36713a29 Mon Sep 17 00:00:00 2001 From: chad1008 <13856531+chad1008@users.noreply.github.com> Date: Wed, 20 Jul 2022 13:35:31 -0400 Subject: [PATCH 1/2] ComboboxControl: refactor `onKeyDown` to use `event.code` --- packages/components/src/combobox-control/index.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/components/src/combobox-control/index.js b/packages/components/src/combobox-control/index.js index ac272f11160312..2440296865c746 100644 --- a/packages/components/src/combobox-control/index.js +++ b/packages/components/src/combobox-control/index.js @@ -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'; @@ -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; From 9c14ba056c9d9fb0264339c86738e74a4514fa5d Mon Sep 17 00:00:00 2001 From: chad1008 <13856531+chad1008@users.noreply.github.com> Date: Thu, 21 Jul 2022 06:17:48 -0400 Subject: [PATCH 2/2] ComboboxControl: update Changelog --- packages/components/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/components/CHANGELOG.md b/packages/components/CHANGELOG.md index 9787549b84f31a..a0220d449aaa68 100644 --- a/packages/components/CHANGELOG.md +++ b/packages/components/CHANGELOG.md @@ -30,6 +30,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)