diff --git a/web/src/components/AskAIDialog.tsx b/web/src/components/AskAIDialog.tsx index fc1f17bd..a3adb304 100644 --- a/web/src/components/AskAIDialog.tsx +++ b/web/src/components/AskAIDialog.tsx @@ -20,6 +20,7 @@ const AskAIDialog: React.FC = (props: Props) => { const fetchingState = useLoading(false); const [historyList, setHistoryList] = useState([]); const [isEnabled, setIsEnabled] = useState(true); + const [isInIME, setIsInIME] = useState(false); const [question, setQuestion] = useState(""); useEffect(() => { @@ -38,15 +39,22 @@ const AskAIDialog: React.FC = (props: Props) => { setQuestion(event.currentTarget.value); }; + const handleKeyDown = (event: React.KeyboardEvent) => { + if (event.key === "Enter" && !event.shiftKey && !isInIME) { + event.preventDefault(); + handleSendQuestionButtonClick(); + } + }; + const handleSendQuestionButtonClick = async () => { fetchingState.setLoading(); + setQuestion(""); try { await askQuestion(question); } catch (error: any) { console.error(error); toast.error(error.response.data.error); } - setQuestion(""); fetchingState.setFinish(); }; @@ -80,7 +88,17 @@ const AskAIDialog: React.FC = (props: Props) => {
-