fix(web): don't submit chat on Enter during IME composition

The chat composers submit on Enter without checking whether an IME
composition is active. For Japanese/Chinese/Korean input, pressing Enter
to confirm a conversion fires the submit handler and sends a half-typed
message. Guard the Enter handlers with e.nativeEvent.isComposing in the
main chat editor, the anonymous free composer, and the mention/prompt
picker key navigation.
This commit is contained in:
yagitoshiro 2026-06-28 13:13:46 +09:00
parent 7093b4d4d0
commit 24ff4b7d93
3 changed files with 10 additions and 2 deletions

View file

@ -696,7 +696,9 @@ export const InlineMentionEditor = forwardRef<InlineMentionEditorRef, InlineMent
onKeyDown?.(e);
if (e.defaultPrevented) return;
if (e.key === "Enter" && !e.shiftKey) {
// Ignore Enter while an IME composition is active (e.g. confirming a
// Japanese/Chinese/Korean conversion) so it doesn't submit the message.
if (e.key === "Enter" && !e.shiftKey && !e.nativeEvent.isComposing) {
e.preventDefault();
onSubmit?.();
return;

View file

@ -713,6 +713,10 @@ const Composer: FC = () => {
// Arrow / Enter / Escape navigation for the active picker.
const handleKeyDown = useCallback(
(e: React.KeyboardEvent) => {
// While an IME composition is active (e.g. confirming a Japanese/Chinese/
// Korean conversion), let the Enter/Arrow keys reach the IME instead of
// driving picker navigation/selection.
if (e.nativeEvent.isComposing) return;
if (showPromptPicker) {
if (e.key === "ArrowDown") {
e.preventDefault();

View file

@ -99,7 +99,9 @@ export const FreeComposer: FC = () => {
gate("mention documents");
return;
}
if (e.key === "Enter" && !e.shiftKey) {
// Ignore Enter while an IME composition is active (e.g. confirming a
// Japanese/Chinese/Korean conversion) so it doesn't submit the message.
if (e.key === "Enter" && !e.shiftKey && !e.nativeEvent.isComposing) {
e.preventDefault();
if (text.trim()) {
aui.composer().send();