From 8520e2fc98518d7d95331f9445ac33c18307f4c9 Mon Sep 17 00:00:00 2001 From: Oliver Roick Date: Fri, 20 Dec 2024 11:02:52 +1100 Subject: [PATCH] Clear input field on button submit --- src/components/ChatInput.jsx | 10 +++++++--- src/main.jsx | 1 - 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/components/ChatInput.jsx b/src/components/ChatInput.jsx index e7e8e89..ed092d9 100644 --- a/src/components/ChatInput.jsx +++ b/src/components/ChatInput.jsx @@ -9,11 +9,15 @@ function ChatInput() { const submit = useSetAtom(addPrompt); + const submitPrompt = () => { + submit({ query: inputValue, queryType: "query" }); + setInputValue(""); + }; + const handleKeyUp = (e) => { if(e.keyCode === 13) { e.preventDefault(); - submit({ query: inputValue, queryType: "query" }); - setInputValue(""); + submitPrompt(); } }; @@ -40,7 +44,7 @@ function ChatInput() { colorPalette="blue" type="button" size="xs" - onClick={() => submit({ query: inputValue, queryType: "query" })} + onClick={submitPrompt} > diff --git a/src/main.jsx b/src/main.jsx index 7732d04..cc6c124 100644 --- a/src/main.jsx +++ b/src/main.jsx @@ -12,7 +12,6 @@ async function deferRender() { } else { return Promise.resolve(); } - } deferRender().then(() => {