mirror of
https://github.com/mattermost/focalboard.git
synced 2025-02-07 19:30:18 +02:00
Fixed bug of stale closure in markdown editor (#2058)
This commit is contained in:
parent
e1d5e77e0e
commit
155bf75718
@ -46,10 +46,21 @@ const MarkdownEditorInput = (props: Props): ReactElement => {
|
||||
}))
|
||||
, [workspaceUsers])
|
||||
const ref = useRef<Editor>(null)
|
||||
const [editorState, setEditorState] = useState(() => {
|
||||
const state = EditorState.createWithContent(ContentState.createFromText(initialText || ''))
|
||||
|
||||
const generateEditorState = (text?: string) => {
|
||||
const state = EditorState.createWithContent(ContentState.createFromText(text || ''))
|
||||
return EditorState.moveSelectionToEnd(state)
|
||||
}
|
||||
|
||||
const [editorState, setEditorState] = useState(() => {
|
||||
return generateEditorState(initialText)
|
||||
})
|
||||
|
||||
// avoiding stale closure
|
||||
useEffect(() => {
|
||||
setEditorState(generateEditorState(initialText))
|
||||
}, [initialText])
|
||||
|
||||
const [isMentionPopoverOpen, setIsMentionPopoverOpen] = useState(false)
|
||||
const [isEmojiPopoverOpen, setIsEmojiPopoverOpen] = useState(false)
|
||||
const [suggestions, setSuggestions] = useState(mentions)
|
||||
|
Loading…
x
Reference in New Issue
Block a user