Merge branch 'compose-text' into 'main'
ComposeForm: get text from the editorRef instead of component state Closes #1563 See merge request soapbox-pub/soapbox!2856
This commit is contained in:
commit
c777d767d2
1 changed files with 2 additions and 3 deletions
|
@ -1,5 +1,5 @@
|
|||
import clsx from 'clsx';
|
||||
import { CLEAR_EDITOR_COMMAND, TextNode, type LexicalEditor } from 'lexical';
|
||||
import { CLEAR_EDITOR_COMMAND, TextNode, type LexicalEditor, $getRoot } from 'lexical';
|
||||
import React, { Suspense, useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
||||
import { Link, useHistory } from 'react-router-dom';
|
||||
|
@ -96,13 +96,13 @@ const ComposeForm = <ID extends string>({ id, shouldCondense, autoFocus, clickab
|
|||
const anyMedia = compose.media_attachments.size > 0;
|
||||
|
||||
const [composeFocused, setComposeFocused] = useState(false);
|
||||
const [text, setText] = useState(compose.text);
|
||||
|
||||
const firstRender = useRef(true);
|
||||
const formRef = useRef<HTMLDivElement>(null);
|
||||
const spoilerTextRef = useRef<AutosuggestInput>(null);
|
||||
const editorRef = useRef<LexicalEditor>(null);
|
||||
|
||||
const text = editorRef.current?.getEditorState().read(() => $getRoot().getTextContent()) ?? '';
|
||||
const { isDraggedOver } = useDraggedFiles(formRef);
|
||||
|
||||
const getClickableArea = () => {
|
||||
|
@ -297,7 +297,6 @@ const ComposeForm = <ID extends string>({ id, shouldCondense, autoFocus, clickab
|
|||
autoFocus={shouldAutoFocus}
|
||||
hasPoll={hasPoll}
|
||||
handleSubmit={handleSubmit}
|
||||
onChange={setText}
|
||||
onFocus={handleComposeFocus}
|
||||
onPaste={onPaste}
|
||||
/>
|
||||
|
|
Loading…
Reference in a new issue