Text cursor moves to the beginning after immediately clear the editor content
See original GitHub issueEnvironment
“draft-js”: “^0.11.7”, “@draft-js-plugins/editor”: “^4.1.0”,
“@draft-js-plugins/emoji”: “^4.5.5”,
Description
I type something in the editor and hit Enter or click the button to clear the editor via EditorState.createEmpty()
.
If I continue to type some words, the text cursor moves to the beginning after I type the first letter.
This problem can be fixed by this method in the original Draft.js Editor. https://github.com/facebook/draft-js/issues/73#issuecomment-191394559 However, this approach doesn’t work in draft-js-plugins/editor
Reproducible Demo
https://codesandbox.io/s/draft-editor-example-ijie2
My solution
In the packages/editor/src/Editor/index.tsx
, I replace moveSelectionToEnd
to EditorState.moveFocusToEnd
in line 111 and 140.
Change from:
this.onChange(moveSelectionToEnd(editorState));
to:
this.onChange(EditorState.moveFocusToEnd(editorState));
After the replacement, this issue is fixed.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Top GitHub Comments
Confirm, same issue
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.