diff --git a/client/src/components/Chat/Input/ChatForm.tsx b/client/src/components/Chat/Input/ChatForm.tsx index 51e9cb5c28..69e4819a99 100644 --- a/client/src/components/Chat/Input/ChatForm.tsx +++ b/client/src/components/Chat/Input/ChatForm.tsx @@ -29,14 +29,11 @@ const ChatForm = ({ index = 0 }) => { defaultValues: { text: '' }, }); - const { handlePaste, handleKeyUp, handleKeyDown, handleCompositionStart, handleCompositionEnd } = - useTextarea({ - textAreaRef, - submitButtonRef, - disabled: !!requiresKey, - setValue: methods.setValue, - getValues: methods.getValues, - }); + const { handlePaste, handleKeyDown, handleCompositionStart, handleCompositionEnd } = useTextarea({ + textAreaRef, + submitButtonRef, + disabled: !!requiresKey, + }); const { ask, @@ -58,9 +55,6 @@ const ChatForm = ({ index = 0 }) => { } ask({ text: data.text }); methods.reset(); - if (textAreaRef.current) { - textAreaRef.current.value = ''; - } }, [ask, methods], ); @@ -84,6 +78,13 @@ const ChatForm = ({ index = 0 }) => { [requiresKey, invalidAssistant], ); + const { ref, ...registerProps } = methods.register('text', { + required: true, + onChange: (e) => { + methods.setValue('text', e.target.value); + }, + }); + return (