Page MenuHomePhabricator

jQueryIME: If contentEditable cursor not in a text node, then insertion goes before the first CE text character
Closed, ResolvedPublic8 Estimated Story Points


Steps to reproduce:

  1. Go to the contentEditable div in
  2. Move the cursor to the end of the content, and press Enter to create a new paragraph (actually <p><br></p> in most browsers).
  3. Enable Malayalam input, and press 'x'
  4. Observe that the text gets inserted at the very start of the contentEditable text, instead of where the cursor is.

This happens because in jquery.ime.js#getDivCaretPosition, traverseTextNodes only checks node === range.startContainer in text nodes. So in the case outlined above, it fails to detect the selection range, and hence the default range of 0-0 is returned.

More generally, the "position" values used by getDivCaretPosition / setDivCaretPosition only count text characters (i.e. code units in text nodes). This would need to change in order to represent offsets that do not lie within a text node. Adding one for each element node entry/exit looks like it can solve this.

Event Timeline

dchan raised the priority of this task from to Needs Triage.
dchan updated the task description. (Show Details)
dchan added subscribers: dchan, Esanders.

I think is ready to merge (it certainly improves CE behaviour overall).

Jdforrester-WMF assigned this task to dchan.
Jdforrester-WMF triaged this task as High priority.
Jdforrester-WMF edited a custom field.
Jdforrester-WMF subscribed.

As of in UniversalLanguageSelector this should now be resolved and working for all users, and will be part of the wmf.12 release starting tomorrow.