Prevent cursor jumps inside contenteditable#2701
Conversation
|
Size Change: +32 B (0%) Total Size: 40.4 kB
ℹ️ View Unchanged
|
|
|
||
| // dispatch a change event | ||
| editable.innerHTML = 'World'; | ||
| editable.dispatchEvent(createEvent('input')); |
There was a problem hiding this comment.
Hmm I don't think I understand this test. How can a real user fire an input event or change the innerHTML but simultaneously keep text selection. My understanding is that all browsers would clear the text selection the moment the user presses a key while selecting text.
There was a problem hiding this comment.
Yeah you're right. I forgot to get back to this. I originally wanted to use the range to place the caret (see https://stackoverflow.com/a/6249440/2164347) but failed. I will try again to make the test clear. In the end this just makes sure we do not touch innerHTML.
There was a problem hiding this comment.
I modified the test to be more realistic. It now ensures the caret stays where it was prior to the input event
|
Awesome work! This seems to take |
This prevents cursor jumps inside contenteditable. It seems a bit expensive to check for innerHTML equality but the only way I see to get this fixed.
Fixes #2691