updated fix for comments display backwards (#2085)

This commit is contained in:
Scott Bishel 2022-01-11 07:47:12 -07:00 committed by GitHub
parent 855ea70a44
commit 9290194529
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -47,12 +47,13 @@ const MarkdownEditorInput = (props: Props): ReactElement => {
, [workspaceUsers])
const ref = useRef<Editor>(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) {