From 79c7dd26037f928df95e7ce1449704900fff1bca Mon Sep 17 00:00:00 2001 From: Jing Hua Date: Sat, 4 Mar 2023 09:56:40 +0800 Subject: [PATCH] feat: resizable textarea --- .../Chat/ChatContent/Message/MessageContent.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/components/Chat/ChatContent/Message/MessageContent.tsx b/src/components/Chat/ChatContent/Message/MessageContent.tsx index e818d88..a9d9502 100644 --- a/src/components/Chat/ChatContent/Message/MessageContent.tsx +++ b/src/components/Chat/ChatContent/Message/MessageContent.tsx @@ -254,15 +254,25 @@ const EditView = ({ ]); const [_content, _setContent] = useState(content); + const textareaRef = React.createRef(); + + const handleInput = (e: React.ChangeEvent) => { + if (textareaRef.current) { + textareaRef.current.style.height = 'auto'; + textareaRef.current.style.height = `${e.target.scrollHeight}px`; + } + }; return ( <>