From 73e9d083dd6f90896aab24bf323c162536117ac7 Mon Sep 17 00:00:00 2001 From: Neil Jenkins Date: Thu, 1 Feb 2024 21:24:11 +1100 Subject: [PATCH] Fix handling of Japanese IME input With the modern keyboard events, the Backspace/Enter handlers were being triggered even when they were part of an IME composition, which broke the native IME handling. We now ignore all keyboard events that are part of composition to avoid this issue. --- source/keyboard/KeyHandlers.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/source/keyboard/KeyHandlers.ts b/source/keyboard/KeyHandlers.ts index 4edda27..e829e83 100644 --- a/source/keyboard/KeyHandlers.ts +++ b/source/keyboard/KeyHandlers.ts @@ -18,7 +18,9 @@ import { moveRangeBoundariesDownTree } from '../range/Boundaries'; // --- const _onKey = function (this: Squire, event: KeyboardEvent): void { - if (event.defaultPrevented) { + // Ignore key events where event.isComposing, to stop us from blatting + // Kana-Kanji conversion + if (event.defaultPrevented || event.isComposing) { return; } @@ -52,9 +54,6 @@ const _onKey = function (this: Squire, event: KeyboardEvent): void { this._keyHandlers[key](this, event, range); } else if ( !range.collapsed && - // !event.isComposing stops us from blatting Kana-Kanji conversion in - // Safari - !event.isComposing && !event.ctrlKey && !event.metaKey && key.length === 1