diff --git a/src/features/compose/components/compose-form.tsx b/src/features/compose/components/compose-form.tsx index 132f8c5c2..db316b138 100644 --- a/src/features/compose/components/compose-form.tsx +++ b/src/features/compose/components/compose-form.tsx @@ -1,5 +1,5 @@ import clsx from 'clsx'; -import { type EditorState } from 'lexical'; +import { CLEAR_EDITOR_COMMAND, type LexicalEditor } from 'lexical'; import React, { useCallback, useEffect, useRef, useState } from 'react'; import { defineMessages, FormattedMessage, useIntl } from 'react-intl'; import { Link, useHistory } from 'react-router-dom'; @@ -108,7 +108,7 @@ const ComposeForm = ({ id, shouldCondense, autoFocus, clickab const formRef = useRef(null); const spoilerTextRef = useRef(null); const autosuggestTextareaRef = useRef(null); - const editorStateRef = useRef(null); + const editorRef = useRef(null); const { isDraggedOver } = useDraggedFiles(formRef); @@ -160,6 +160,7 @@ const ComposeForm = ({ id, shouldCondense, autoFocus, clickab } dispatch(submitCompose(id, history)); + editorRef.current?.dispatchCommand(CLEAR_EDITOR_COMMAND, undefined); }; const onSuggestionsClearRequested = () => { @@ -315,7 +316,7 @@ const ComposeForm = ({ id, shouldCondense, autoFocus, clickab {(Component: any) => ( (({ +const ComposeEditor = React.forwardRef(({ className, placeholderClassName, composeId, @@ -157,7 +158,7 @@ const ComposeEditor = React.forwardRef(({ { onChange?.(editor.getEditorState().read(() => $getRoot().getTextContent())); if (editorStateRef && typeof editorStateRef !== 'function') { - editorStateRef.current = editor.getEditorState(); + editorStateRef.current = editor; } }} /> @@ -168,6 +169,7 @@ const ComposeEditor = React.forwardRef(({ + );