diff --git a/src/components/TextareaComposer/TextareaComposer.tsx b/src/components/TextareaComposer/TextareaComposer.tsx index 41498e6f1..d0357cc11 100644 --- a/src/components/TextareaComposer/TextareaComposer.tsx +++ b/src/components/TextareaComposer/TextareaComposer.tsx @@ -1,11 +1,15 @@ import clsx from 'clsx'; -import type { - ChangeEventHandler, - SyntheticEvent, - TextareaHTMLAttributes, - UIEventHandler, +import React, { + type ChangeEventHandler, + type SyntheticEvent, + type TextareaHTMLAttributes, + type UIEventHandler, + useCallback, + useEffect, + useLayoutEffect, + useRef, + useState, } from 'react'; -import React, { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react'; import Textarea from 'react-textarea-autosize'; import { useCooldownRemaining } from '../MessageComposer/hooks/useCooldownRemaining'; import { useMessageComposerController } from '../MessageComposer/hooks/useMessageComposerController'; @@ -263,6 +267,13 @@ export const TextareaComposer = ({ textareaRef.current.focus(); }, [attachments, focus, quotedMessage, textareaRef]); + useEffect( + () => () => { + messageComposer.clear(); + }, + [messageComposer], + ); + useLayoutEffect(() => { /** * It is important to perform set text and after that the range