mirror of
https://github.com/All-Hands-AI/OpenHands.git
synced 2026-01-07 22:14:03 -05:00
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:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user