diff --git a/web/src/components/message-input/index.tsx b/web/src/components/message-input/index.tsx index 751c1f4a75a..4f3de100d24 100644 --- a/web/src/components/message-input/index.tsx +++ b/web/src/components/message-input/index.tsx @@ -156,8 +156,14 @@ const MessageInput = ({ setFileList([]); }, [fileList, onPressEnter, isUploadingFile]); + const [isComposing, setIsComposing] = useState(false); + + const handleCompositionStart = () => setIsComposing(true); + const handleCompositionEnd = () => setIsComposing(false); + const handleInputKeyDown: KeyboardEventHandler = (e) => { if (e.key === 'Enter' && !e.nativeEvent.shiftKey) { + if (isComposing || sendLoading) return; e.preventDefault(); handlePressEnter(); } @@ -221,6 +227,8 @@ const MessageInput = ({ })} onKeyDown={handleInputKeyDown} onChange={onInputChange} + onCompositionStart={handleCompositionStart} + onCompositionEnd={handleCompositionEnd} autoSize={{ minRows: 1, maxRows: 6 }} />