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 is added at wrong caret position in text area

See original GitHub issue

Initilization Code CodeMirror.fromTextArea($(".edit-box", this.element)[0], { mode: "text/html", lineNumbers: true, lineWrapping: true });

On adding text in editor sometimes the text is added in the wrong position as shown in the GIF below This issue is tested on version 3.21.0 and 5.48.4 Steps to reproduce.

  1. Open the editor add text in it.
  2. Click on the end of any word and then click on the start of the next word.
  3. Type anything, it will be added to wrong position.

Code Pen https://codepen.io/ahtishamshahid/pen/pooLqeJ

codeMirrorBug

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
awaisdar001commented, Nov 6, 2019

I’m not able to reproduce this. Does it happen in the demos on the website?

I am able to reproduce by writing a long line without hitting an enter. If you copy paste this line in the editor you will be able to reproduce the bug. Or any long line will do. I tried.

Ok this is a new line i am trying to write, but it seems like the line is going to be long enough that the curser will move to the new and we will be able to reproduce the bug. 
0reactions
gillsignalscommented, Nov 7, 2019

Several users of the edX content editing platform have been experiencing this issue as well, and their engineers traced the problem back to CodeMirror and referred us to watch this issue. It is definitely affecting a live version of your product.

I sent a note to them to provide you more information, as I am unclear how edX implements CodeMirror, but I can verify that many users worldwide are experiencing this problem and we have an internal discussion board with several reports.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Text is added at wrong caret position in codemirror text area
Open the editor add text in it. · Click on the end of any word and then click on the start of the...
Read more >
Position is wrong, if text ist longer than inputbox/textarea #51
Since the package is forcing white-space: pre-wrap on the input as well as textarea there is no easy way around this.
Read more >
How to set and get cursor position in a text area - TinyMCE
Setting the cursor position · 1. Select content, and then bookmark the position of the content · 2. Set the caret position on...
Read more >
How to insert text into the textarea at the current cursor position?
First, get the current position of cursor with the help of property named as selectionStart on textarea/inputbox. To insert the text at the ......
Read more >
HOW TO: Where's the text cursor? | by Jhey Tompkins | Medium
Showing the cursor position on input and click ... Let's walk through one of the demo scenarios. The desired behavior is that whenever...
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