Fix: Prevent Enter key from submitting during IME composition

When using an Input Method Editor (IME) for Chinese, Japanese, or Korean
input, pressing Enter should confirm the IME composition rather than
submit the chat message. This fix adds a check for isComposing to ignore
Enter key presses during active IME composition.

Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
openhands
2026-01-03 20:05:13 +00:00
parent 8c73c87583
commit eb80c92747
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();