insertAtCaret icon indicating copy to clipboard operation
insertAtCaret copied to clipboard

Inserts text into wrong spot after hitting backspace in Chrome

Open alimovz opened this issue 7 years ago • 2 comments

Let's say I have this text in a textarea:

insert zipcode into your text

If I then use backspace to delete the word "zipcode" and insertAtCaret, it will insert like this:

insert into y85666our text

See, it still thinks the cursor is at it's old location. This only happens in Chrome.

alimovz avatar Jun 07 '17 19:06 alimovz

Yep, I can replicate the issue but it's a bug of Chrome. I don't know how we can manage to fix it. Do you have any idea?

emreerkan avatar Jun 08 '17 22:06 emreerkan

I really do not know how to do it programmatically within the context of your plugin, but conceptually it would be something like this: Detect if the user is in Chrome and keep track of any backspace presses. Then upon inserting the caret, count back the position by the amount of backspaces pressed and insert it there instead of the current spot. Something like that I guess.

alimovz avatar Jun 09 '17 03:06 alimovz

Hi @alimovz,

It seems Chrome has fixed the bug and it's not an issue right now. I created a fiddle here and tested on Chrome(v114 - arm64). I couldn'r replicate the issue. I'm going to close this issue. If you can replicate and create a test case, please reopen it and let me know.

emreerkan avatar Jun 18 '23 05:06 emreerkan