Skip to content

Commit

Permalink
Chat: Fix form resets (#260)
Browse files Browse the repository at this point in the history
  • Loading branch information
richardgill committed Jun 1, 2024
1 parent 3958ca6 commit 3a06746
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions apps/www/src/components/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ export const Chat = () => {
setSelectedChatGptModel(value);
};

const onSubmit = (e: React.FormEvent<HTMLFormElement>) => {
const onSubmit = (e: React.FormEvent) => {
setError(undefined);
storage?.setItem(CHAT_OPENAI_API_KEY, currentApiKey);
scrollToBottom();
handleSubmit(e);
handleSubmit(e as unknown as React.FormEvent<HTMLFormElement>);
};

const messagesWithoutSystem = messages.slice(1);
Expand Down Expand Up @@ -152,11 +152,7 @@ export const Chat = () => {
}}
/>
</div>
<form
autoComplete="off"
onSubmit={onSubmit}
className="flex flex-col flex-1 overflow-y-hidden"
>
<div className="flex flex-col flex-1 overflow-y-hidden">
{/* Col-reverse is used to enable automatic scrolling as content populates the div */}
<div
ref={messagesDivRef}
Expand Down Expand Up @@ -236,13 +232,13 @@ export const Chat = () => {
<Button
disabled={isLoading || !input}
className="self-end"
type="submit"
onClick={onSubmit}
>
Run <Icons.return className="size-4 ml-2" />
</Button>
</div>
</div>
</form>
</div>
</div>
);
};

0 comments on commit 3a06746

Please sign in to comment.