diff --git a/web/screens/Chat/index.tsx b/web/screens/Chat/index.tsx index 9f6dba38e6..8f2e30e094 100644 --- a/web/screens/Chat/index.tsx +++ b/web/screens/Chat/index.tsx @@ -75,19 +75,14 @@ const ChatScreen = () => { // eslint-disable-next-line react-hooks/exhaustive-deps }, [waitingToSendMessage, activeThreadId]) - useEffect(() => { - if (textareaRef.current !== null) { - const scrollHeight = textareaRef.current.scrollHeight - if (currentPrompt.length === 0) { - textareaRef.current.style.height = '40px' - } else { - textareaRef.current.style.height = `${ - scrollHeight < 40 ? 40 : scrollHeight - }px` - } + const resizeTextArea = () => { + if (textareaRef.current) { + textareaRef.current.style.height = '40px' + textareaRef.current.style.height = textareaRef.current.scrollHeight + 'px' } - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [currentPrompt]) + } + + useEffect(resizeTextArea, [currentPrompt]) const onKeyDown = async (e: React.KeyboardEvent) => { if (e.key === 'Enter') { @@ -155,7 +150,8 @@ const ChatScreen = () => { )}