Skip to content

Commit f2a79ab

Browse files
authored
fix: clear message composer on unmount (#3053)
1 parent da293f0 commit f2a79ab

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

src/components/TextareaComposer/TextareaComposer.tsx

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
import clsx from 'clsx';
2-
import type {
3-
ChangeEventHandler,
4-
SyntheticEvent,
5-
TextareaHTMLAttributes,
6-
UIEventHandler,
2+
import React, {
3+
type ChangeEventHandler,
4+
type SyntheticEvent,
5+
type TextareaHTMLAttributes,
6+
type UIEventHandler,
7+
useCallback,
8+
useEffect,
9+
useLayoutEffect,
10+
useRef,
11+
useState,
712
} from 'react';
8-
import React, { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';
913
import Textarea from 'react-textarea-autosize';
1014
import { useCooldownRemaining } from '../MessageComposer/hooks/useCooldownRemaining';
1115
import { useMessageComposerController } from '../MessageComposer/hooks/useMessageComposerController';
@@ -263,6 +267,13 @@ export const TextareaComposer = ({
263267
textareaRef.current.focus();
264268
}, [attachments, focus, quotedMessage, textareaRef]);
265269

270+
useEffect(
271+
() => () => {
272+
messageComposer.clear();
273+
},
274+
[messageComposer],
275+
);
276+
266277
useLayoutEffect(() => {
267278
/**
268279
* It is important to perform set text and after that the range

0 commit comments

Comments
 (0)