Page MenuHomePhabricator

[Regression wmf18] Deleting the text inside a bullet/numbered item, heading, other nodes throws error
Closed, ResolvedPublic1 Estimated Story Points

Description

Steps to reproduce:

1.Open a page with VE
2.Click on bullet list or numbered list icon
3.Now type a text
4.Press enter and go to the next line
5.And then go back to the end of first bulleted or numbered item
6.Delete the text until it deletes the bullet point or the number

Observed that, it throws this error in the console:Error: Offset could not be translated to a DOM element and offset

Now if you go to the second bullet/numbered point and type some text watch text being typed randomly or sometimes deleting the second point entirely.Also there are more error keeps popping in the console as you try to edit the page:

Error: Invalid retain length, cannot retain backwards:-2
Uncaught TypeError: Cannot read property 'insertBefore' of null

Event Timeline

Ryasmeen raised the priority of this task from to Needs Triage.
Ryasmeen updated the task description. (Show Details)
Ryasmeen subscribed.
Ryasmeen set Security to None.

Happens in both Chrome and Firefox

Ryasmeen renamed this task from [Regression wmf 18] Error: Offset could not be translated to a DOM element and offset appears while deleting the text inside a bullet/numbered item and then cursor starts behaving weirdly while typing text to [Regression wmf 18] "Error: Offset could not be translated to a DOM element and offset" appears while deleting the text inside a bullet/numbered item and then cursor starts behaving weirdly while typing text .Feb 23 2015, 7:49 PM
Ryasmeen moved this task from To Triage to External and Administrivia on the VisualEditor board.
Ryasmeen updated the task description. (Show Details)
Jdforrester-WMF renamed this task from [Regression wmf 18] "Error: Offset could not be translated to a DOM element and offset" appears while deleting the text inside a bullet/numbered item and then cursor starts behaving weirdly while typing text to [Regression wmf18] Deleting the text inside a bullet/numbered item throws error .Feb 24 2015, 11:59 PM
Jdforrester-WMF edited a custom field.
Jdforrester-WMF renamed this task from [Regression wmf18] Deleting the text inside a bullet/numbered item throws error to [Regression wmf18] Deleting the text inside a bullet/numbered item, heading, other nodes throws error .Feb 25 2015, 6:42 PM
Jdforrester-WMF added a subscriber: matmarex.

James guilted me into debugging this a bit. A good place to put a breakpoint when debugging this is in ve.dm.SurfaceFragment.prototype.delete after this line: tx = ve.dm.Transaction.newFromRemoval( this.document, rangeToRemove );. Astonishingly, the removal transation turns out not to have any remove operations. The list item gets removed anyway for some reason (on the next line), but the selection range is not correctly translated to account for that (on the next next line) and so the offset ends up in the middle of nowhere. I'll leave figuring out why this happens to someone else.

I think the model is a red herring here. I think the problem is the state of the CE, and missing inline slugs.

...caused by the introduction of allowing native delete, so the bug is set up by the delete operation *before* the one which throws an exception, as it removes the valid cursor position the next operation expects when calling an intermediary showSelection.

Change 196224 had a related patch set uploaded (by Divec):
Stop bogus emits from handleLinearDelete

https://gerrit.wikimedia.org/r/196224

The missing slug allows the exception to occur, but it happens too because the SurfaceFragment performing the deletion has autoSelect and applies a nonsensical selection midway through processing (before subsequently applying the selection that is actually desired). The patch addresses this by turning off autoSelect and then selecting once only, after content processing is complete.

Change 196224 merged by jenkins-bot:
Stop bogus emits from handleLinearDelete

https://gerrit.wikimedia.org/r/196224

Change 196314 had a related patch set uploaded (by Jforrester):
Stop bogus emits from handleLinearDelete

https://gerrit.wikimedia.org/r/196314

Change 196315 had a related patch set uploaded (by Jforrester):
Stop bogus emits from handleLinearDelete

https://gerrit.wikimedia.org/r/196315

Change 196315 merged by jenkins-bot:
Stop bogus emits from handleLinearDelete

https://gerrit.wikimedia.org/r/196315

Change 196314 merged by jenkins-bot:
Stop bogus emits from handleLinearDelete

https://gerrit.wikimedia.org/r/196314