diff --git a/src/components/Chat/ChatContent/Message/MessageContent.tsx b/src/components/Chat/ChatContent/Message/MessageContent.tsx index d82ebb4..5ad4487 100644 --- a/src/components/Chat/ChatContent/Message/MessageContent.tsx +++ b/src/components/Chat/ChatContent/Message/MessageContent.tsx @@ -291,6 +291,10 @@ const EditView = ({ const [isModalOpen, setIsModalOpen] = useState(false); const textareaRef = React.createRef(); + const resetTextAreaHeight = () => { + if (textareaRef.current) textareaRef.current.style.height = 'auto'; + }; + const handleInput = (e: React.ChangeEvent) => { if (textareaRef.current) { textareaRef.current.style.height = 'auto'; @@ -301,8 +305,10 @@ const EditView = ({ const handleKeyDown = (e: React.KeyboardEvent) => { if ((e.ctrlKey || e.shiftKey) && e.key === 'Enter') { e.preventDefault(); - if (sticky) handleSaveAndSubmit(); - else handleSave(); + if (sticky) { + handleSaveAndSubmit(); + resetTextAreaHeight(); + } else handleSave(); } }; @@ -314,6 +320,7 @@ const EditView = ({ if (sticky) { updatedMessages.push({ role: inputRole, content: _content }); _setContent(''); + resetTextAreaHeight(); } else { updatedMessages[messageIndex].content = _content; setIsEdit(false); @@ -331,6 +338,7 @@ const EditView = ({ updatedMessages.push({ role: inputRole, content: _content }); _setContent(''); setMessages(updatedMessages); + resetTextAreaHeight(); } else { updatedMessages[messageIndex].content = _content; const _updatedMessages = updatedMessages.slice(0, messageIndex + 1);