Fix: Prevent Enter key from submitting during IME composition (#12252)

Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
Xingyao Wang
2026-01-09 22:34:25 -05:00
committed by GitHub
parent 778a1cf609
commit 175117e8b5
3 changed files with 14 additions and 0 deletions

View File

@@ -30,6 +30,10 @@ export function ConversationCardTitle({
onSave(trimmed);
}}
onKeyUp={(event: React.KeyboardEvent<HTMLInputElement>) => {
// Ignore Enter key during IME composition (e.g., Chinese, Japanese, Korean input)
if (event.nativeEvent.isComposing) {
return;
}
if (event.key === "Enter") {
event.currentTarget.blur();
}

View File

@@ -91,6 +91,10 @@ export function ConversationName() {
};
const handleKeyUp = (event: React.KeyboardEvent<HTMLInputElement>) => {
// Ignore Enter key during IME composition (e.g., Chinese, Japanese, Korean input)
if (event.nativeEvent.isComposing) {
return;
}
if (event.key === "Enter") {
event.currentTarget.blur();
}

View File

@@ -68,6 +68,12 @@ export const useChatInputEvents = (
return;
}
// Ignore Enter key during IME composition (e.g., Chinese, Japanese, Korean input)
// When using IME, Enter is used to confirm the composition, not to submit
if (e.nativeEvent.isComposing) {
return;
}
if (checkIsContentEmpty()) {
e.preventDefault();
increaseHeightForEmptyContent();