fix(keymap): Don't run the Enter that commits an input-method candidate

WebKit sends the Enter (or Space) that commits a candidate after compositionend,
with isComposing already false and keyCode 229. Handlers that checked isComposing
alone ran it: dialogs confirmed and shortcuts fired while typing Chinese or
Japanese. isImeKey() checks both, and every keydown handler that skipped
composition uses it.
Цей коміт міститься в:
l0ng-ai committed 2026-10-27 17:16:46 +08:00
1 джерело 2c576418cb
коміт f73c0a6b1d
10 files changed
+26 -9

No files matched your search

+2 -1
Переглянути файл
@@ -8,6 +8,7 @@ import { FOCUSABLE, onWindowDeactivate, openLayer, trapTab } from "./popupState"
import { useTx } from "@/platform/i18n";
import { selectableText } from "./selectableText";
import styles from "./Dialog.module.css";
import { isImeKey } from "@/platform/ime";
/**
* `default`: filled accent button, triggered by Enter. `cancel`: Esc / close
@@ -256,7 +257,7 @@ function DialogInner({
onCloseRef.current();
} else if (e.key === "Tab") {
trapTab(e, ref.current);
} else if (e.key === "Enter" && !e.defaultPrevented && !e.isComposing && !e.shiftKey && !e.altKey) {
} else if (e.key === "Enter" && !e.defaultPrevented && !isImeKey(e) && !e.shiftKey && !e.altKey) {
const t = e.target instanceof Element ? e.target : null;
const mod = e.metaKey || e.ctrlKey;
if (t && t !== document.body && !ref.current.contains(t)) return;