From 7f39bbf5b0dfe7460d53fa8d286b24c6c795a41e Mon Sep 17 00:00:00 2001 From: Jing Hua Date: Sat, 4 Mar 2023 10:05:15 +0800 Subject: [PATCH] textarea improvements --- .../Chat/ChatContent/Message/MessageContent.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/Chat/ChatContent/Message/MessageContent.tsx b/src/components/Chat/ChatContent/Message/MessageContent.tsx index a9d9502..71cfc43 100644 --- a/src/components/Chat/ChatContent/Message/MessageContent.tsx +++ b/src/components/Chat/ChatContent/Message/MessageContent.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React, { useEffect, useState } from 'react'; import ReactMarkdown from 'react-markdown'; import hljs from 'highlight.js'; import DOMPurify from 'dompurify'; @@ -263,6 +263,13 @@ const EditView = ({ } }; + useEffect(() => { + if (textareaRef.current) { + textareaRef.current.style.height = 'auto'; + textareaRef.current.style.height = `${textareaRef.current.scrollHeight}px`; + } + }, []); + return ( <>