0
Fork 0
mirror of https://github.com/fastmail/Squire.git synced 2024-12-21 23:03:11 -05:00

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.
This commit is contained in:
Neil Jenkins 2024-02-01 21:24:11 +11:00
parent b415665d01
commit 73e9d083dd

View file

@ -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