diff --git a/components/Chat/ChatInput.tsx b/components/Chat/ChatInput.tsx index cf9f4606..234b62e2 100644 --- a/components/Chat/ChatInput.tsx +++ b/components/Chat/ChatInput.tsx @@ -8,6 +8,7 @@ interface Props { export const ChatInput: FC = ({ onSend }) => { const [content, setContent] = useState(); + const [isTyping, setIsTyping] = useState(false); const textareaRef = useRef(null); @@ -31,7 +32,7 @@ export const ChatInput: FC = ({ onSend }) => { }; const handleKeyDown = (e: KeyboardEvent) => { - if (e.key === "Enter" && !e.shiftKey) { + if (!isTyping && e.key === "Enter" && !e.shiftKey) { e.preventDefault(); handleSend(); } @@ -54,6 +55,8 @@ export const ChatInput: FC = ({ onSend }) => { placeholder="Type a message..." value={content} rows={1} + onCompositionStart={() => setIsTyping(true)} + onCompositionEnd={() => setIsTyping(false)} onChange={handleChange} onKeyDown={handleKeyDown} />