From 76415e17bb0691b96f724863a63e30c1b009a4e7 Mon Sep 17 00:00:00 2001 From: Bianca Wentzel Date: Mon, 2 Sep 2024 16:20:55 +0200 Subject: [PATCH] Added keydown event to input to trigger bot --- assets/js/Containers/FrevaGPT/index.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/assets/js/Containers/FrevaGPT/index.js b/assets/js/Containers/FrevaGPT/index.js index 29428ca9..e4c1d0bd 100644 --- a/assets/js/Containers/FrevaGPT/index.js +++ b/assets/js/Containers/FrevaGPT/index.js @@ -113,10 +113,6 @@ const ChatBot = () => { setAnswerLoading(false); } - function handleInputChange(event) { - setQuestion(event.target.value); - } - function handleBotRequest(){ const newQuestion = {type: 'question', content: question}; setConversation(prevConversation => [...prevConversation, newQuestion]); @@ -125,6 +121,16 @@ const ChatBot = () => { requestBot(); } + function handleInputChange(event) { + setQuestion(event.target.value); + } + + function handleKeyDown(event) { + if (event.key === "Enter") { + handleBotRequest(); + } + } + return (
@@ -142,7 +148,7 @@ const ChatBot = () => { {answerLoading ? () : null}
- +