emojionearea icon indicating copy to clipboard operation
emojionearea copied to clipboard

Wrong initial cursor position in Firefox

Open jsmitjans opened this issue 4 years ago • 10 comments

Im using the plugin to send messages with a textarea. Pressing enter the message is sent and the editor is cleaned. My problem is that it always generates some "br" tags and I don't know how to remove them or how to put the cursor in the initial position .

jsmitjans avatar Mar 16 '20 00:03 jsmitjans

Please create example at jsfiddle https://jsfiddle.net/mervick/1v03Lqnu/765/

mervick avatar Mar 16 '20 07:03 mervick

https://jsfiddle.net/ovj6dy1n/ This is the link.Please note that when you type something and press enter the cursor goes down one line. I think if you press enter without having previously pressed the shift key, the cursor remains on the same line.

jsmitjans avatar Mar 16 '20 13:03 jsmitjans

event.preventDefault(); fixes this behavior https://jsfiddle.net/mervick/b8oju234/1/

mervick avatar Mar 16 '20 13:03 mervick

That worked!!The other thing I found is that if you remove the placeholder option the initial cursor position is outside the text box

jsmitjans avatar Mar 16 '20 13:03 jsmitjans

Please create an example at jsfiddle

mervick avatar Mar 16 '20 14:03 mervick

Here is the link. https://jsfiddle.net/e408uqgv/. When the text box is clicked the initial cursor position is outside it

jsmitjans avatar Mar 16 '20 14:03 jsmitjans

It's ok on my browser

mervick avatar Mar 16 '20 14:03 mervick

I've seen this before on either Firefox or IE, I cant remember which.

I worked around it by setting an empty placeholder

carpii avatar Mar 16 '20 14:03 carpii

The problem is on Firefox

jsmitjans avatar Mar 16 '20 14:03 jsmitjans

It's a firefox bug, reported 7 years ago. But developers does not fixed yet.
refs: https://bugzilla.mozilla.org/show_bug.cgi?id=904846 https://bugzilla.mozilla.org/show_bug.cgi?id=550434 https://stackoverflow.com/questions/21986985/firefox-sets-wrong-caret-position-contenteditable-with-before

mervick avatar Mar 16 '20 14:03 mervick