From 9290194529484f073b0de2ebfc9d0d84d99384e3 Mon Sep 17 00:00:00 2001 From: Scott Bishel Date: Tue, 11 Jan 2022 07:47:12 -0700 Subject: [PATCH] updated fix for comments display backwards (#2085) --- .../markdownEditorInput/markdownEditorInput.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/webapp/src/components/markdownEditorInput/markdownEditorInput.tsx b/webapp/src/components/markdownEditorInput/markdownEditorInput.tsx index f93a2aefa..1ecc13107 100644 --- a/webapp/src/components/markdownEditorInput/markdownEditorInput.tsx +++ b/webapp/src/components/markdownEditorInput/markdownEditorInput.tsx @@ -47,12 +47,13 @@ const MarkdownEditorInput = (props: Props): ReactElement => { , [workspaceUsers]) const ref = useRef(null) - const generateEditorState = (text?: string): EditorState => { - return EditorState.createWithContent(ContentState.createFromText(text || '')) + const generateEditorState = (text?: string) => { + const state = EditorState.createWithContent(ContentState.createFromText(text || '')) + return EditorState.moveSelectionToEnd(state) } const [editorState, setEditorState] = useState(() => { - return EditorState.moveSelectionToEnd(generateEditorState(initialText)) + return generateEditorState(initialText) }) // avoiding stale closure @@ -91,7 +92,7 @@ const MarkdownEditorInput = (props: Props): ReactElement => { } setTimeout(() => ref.current?.focus(), 200) } - }, [isEditing]) + }, [isEditing, initialText]) const customKeyBindingFn = useCallback((e: React.KeyboardEvent) => { if (isMentionPopoverOpen || isEmojiPopoverOpen) {