Skip to content

Commit d1f6b4c

Browse files
committed
fix(chat): ignore Enter key while IME is composing
1 parent aedcda8 commit d1f6b4c

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

packages/workshop-frontend/src/ChatInterface.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1835,6 +1835,7 @@ export const ChatInput = ({
18351835
}) => {
18361836
const toasts = useKumoToastManager();
18371837
const [inputValue, setInputValue] = useState("");
1838+
const [isComposing, setIsComposing] = useState(false);
18381839
const [capsules, setCapsules] = useState<InputCapsule[]>([]);
18391840
const [pendingAttachments, setPendingAttachments] = useState<PendingAttachment[]>([]);
18401841
const [isSending, setIsSending] = useState(false);
@@ -3099,6 +3100,8 @@ export const ChatInput = ({
30993100
onSelect={handleCursorChange}
31003101
onClick={handleCursorChange}
31013102
onKeyUp={handleCursorChange}
3103+
onCompositionStart={() => setIsComposing(true)}
3104+
onCompositionEnd={() => setIsComposing(false)}
31023105

31033106
onMouseDown={(e) => {
31043107
if (e.button !== 0) return;
@@ -3199,8 +3202,8 @@ export const ChatInput = ({
31993202
return;
32003203
}
32013204
}
3202-
// Enter sends message (unless Shift is held)
3203-
if (e.key === "Enter" && !e.shiftKey) {
3205+
// Enter sends message unless Shift is held or IME is composing
3206+
if (e.key === "Enter" && !e.shiftKey && !isComposing && !e.nativeEvent?.isComposing) {
32043207
e.preventDefault();
32053208
if (!isAgentActive && !isBlocked) submitMessage();
32063209
return;

0 commit comments

Comments
 (0)