Skip to content

Commit

Permalink
ComboboxControl: Fix unexpected behaviour in IME Composition (#46827)
Browse files Browse the repository at this point in the history
* ComboboxControl: Fix unexpected behaviour in IME Composition

* Update changelog
  • Loading branch information
t-hamano authored Jan 4, 2023
1 parent bcb482e commit 26b69a4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
- `Modal`: Fix unexpected modal closing in IME Composition ([#46453](https://github.com/WordPress/gutenberg/pull/46453)).
- `Toolbar`: Fix duplicate focus style on anchor link button ([#46759](https://github.com/WordPress/gutenberg/pull/46759)).
- `useNavigateRegions`: Ensure region navigation picks the next region based on where the current user focus is located instead of starting at the beginning ([#44883](https://github.com/WordPress/gutenberg/pull/44883)).
- `ComboboxControl`: Fix unexpected behaviour in IME Composition ([#46827](https://github.com/WordPress/gutenberg/pull/46827)).

### Enhancements

Expand Down
10 changes: 9 additions & 1 deletion packages/components/src/combobox-control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,15 @@ function ComboboxControl( {
const onKeyDown = ( event ) => {
let preventDefault = false;

if ( event.defaultPrevented ) {
if (
event.defaultPrevented ||
// Ignore keydowns from IMEs
event.nativeEvent.isComposing ||
// Workaround for Mac Safari where the final Enter/Backspace of an IME composition
// is `isComposing=false`, even though it's technically still part of the composition.
// These can only be detected by keyCode.
event.keyCode === 229
) {
return;
}

Expand Down

0 comments on commit 26b69a4

Please sign in to comment.