From 7979914fb8f4aecf634ece7ef2c48127a47b8c16 Mon Sep 17 00:00:00 2001 From: Hiroshi Urabe Date: Fri, 21 Jul 2023 23:58:54 +0900 Subject: [PATCH] PreventDefault when isComposing is true. apply patch from t-hamano. see: https://github.com/WordPress/gutenberg/issues/52821#issuecomment-1645523477 --- .../commands/src/components/command-menu.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/packages/commands/src/components/command-menu.js b/packages/commands/src/components/command-menu.js index b4a828f34303d..aa77925763007 100644 --- a/packages/commands/src/components/command-menu.js +++ b/packages/commands/src/components/command-menu.js @@ -201,6 +201,20 @@ export function CommandMenu() { if ( ! isOpen ) { return false; } + + const onKeyDown = ( event ) => { + if ( + // 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 + ) { + event.preventDefault(); + } + }; + const isLoading = Object.values( loaders ).some( Boolean ); return ( @@ -211,7 +225,10 @@ export function CommandMenu() { __experimentalHideHeader >
- +