Skip to content

Commit

Permalink
Merge pull request #14 from wri/fix-clear-input
Browse files Browse the repository at this point in the history
Clear input field on button submit
  • Loading branch information
kamicut authored Dec 20, 2024
2 parents 9828923 + 8520e2f commit 1d5d688
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/components/ChatInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
};

Expand All @@ -40,7 +44,7 @@ function ChatInput() {
colorPalette="blue"
type="button"
size="xs"
onClick={() => submit({ query: inputValue, queryType: "query" })}
onClick={submitPrompt}
>
<MdChevronRight />
</Button>
Expand Down
1 change: 0 additions & 1 deletion src/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ async function deferRender() {
} else {
return Promise.resolve();
}

}

deferRender().then(() => {
Expand Down

0 comments on commit 1d5d688

Please sign in to comment.