diff --git a/src/components/SearchChat/AutoResizeTextarea.tsx b/src/components/SearchChat/AutoResizeTextarea.tsx index cfd6527f..2cce1e9a 100644 --- a/src/components/SearchChat/AutoResizeTextarea.tsx +++ b/src/components/SearchChat/AutoResizeTextarea.tsx @@ -3,13 +3,14 @@ import { useEffect, useRef, useImperativeHandle, forwardRef } from "react"; interface AutoResizeTextareaProps { input: string; setInput: (value: string) => void; + handleKeyDown?: (e: React.KeyboardEvent) => void; } // Forward ref to allow parent to interact with this component const AutoResizeTextarea = forwardRef< { reset: () => void; focus: () => void }, AutoResizeTextareaProps ->(({ input, setInput }, ref) => { +>(({ input, setInput, handleKeyDown }, ref) => { const textareaRef = useRef(null); useEffect(() => { @@ -41,6 +42,7 @@ const AutoResizeTextarea = forwardRef< placeholder="Ask whatever you want ..." value={input} onChange={(e) => setInput(e.target.value)} + onKeyDown={handleKeyDown} rows={1} style={{ resize: "none", // Prevent manual resize diff --git a/src/components/SearchChat/InputBox.tsx b/src/components/SearchChat/InputBox.tsx index 5268ca75..abfe09c5 100644 --- a/src/components/SearchChat/InputBox.tsx +++ b/src/components/SearchChat/InputBox.tsx @@ -106,6 +106,12 @@ export default function ChatInput({ ref={textareaRef} input={inputValue} setInput={changeInput} + handleKeyDown={(e) => { + if (e.key === "Enter") { + e.preventDefault(); + handleSubmit(); + } + }} /> ) : (