question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Text cursor moves to the beginning after immediately clear the editor content

See original GitHub issue

Environment

“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:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

4reactions
exectocommented, Mar 8, 2022

Confirm, same issue

0reactions
stale[bot]commented, Jul 30, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Visual Studio code" cursor moves to end of line automatically ...
Here is the simple solution of your problem: Go to File , then toggle Auto Save option.
Read more >
The Curious Case of Cursor Jumping - Mutually Human
Cursor jumping is simply when the cursor jumps from one location to another, unexpectedly, while the user is typing into a text field....
Read more >
Jumping cursor in Gutenberg editor | WordPress.org
When editing text the cursor keeps jumping to the beginning of the paragraph or to random places. It's very annoying and causes typos...
Read more >
Basic VI Editor Commands - Marquette University
Basic VI Editor Commands from the Department of Mathematical and Statistical ... which will move the cursor, delete text, copy and paste, save...
Read more >
Use a text cursor to navigate & select text - Google Chrome Help
Turn on caret browsing · On your computer, open Chrome Chrome . · Select More Organize and then Settings. · At the bottom...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found