Page MenuHomePhabricator

Model and view out of sync when link deleted and replaced with text
Closed, ResolvedPublic8 Estimated Story Points

Description

It is really great how VE now communicates whether you are inside the link context or outside of it as you edit a link element.

It works quite well in general but I found a small issue worth documenting.
When adding an external link by pasting it into the document, the next action is to rename the label. If the label is removed character by character until the item is empty you can still add the new label. But as soon you continue editing somewhere else, the link gets lost.

I captured that in an animated gif for more clarity:

link-issue.gif (300×480 px, 67 KB)

I tried alternative approaches like editing the label first or even selecting it with a double-click, and both worked well.

Event Timeline

Pginer-WMF raised the priority of this task from to Needs Triage.
Pginer-WMF updated the task description. (Show Details)
Pginer-WMF added a project: VisualEditor.
Pginer-WMF subscribed.
Esanders renamed this task from Link context lost after renaming external link to Model and view out of sync when link deleted and replaced with text.Oct 26 2015, 3:54 PM
Esanders assigned this task to dchan.

Not limited to link annotations, get the same issue with bold (in Chrome)

Hmm, this is happening because the model's context-based annotation inference fails if the model context does not have any text with the link annotation.

It would be fixed by the approach of https://gerrit.wikimedia.org/r/247800/ , but perhaps we should special-case this immediately by saving the annotation inside the link DOM element.

BTW this looks like a special case of T116269 but isn't - the difference is in this case, the actual link element remains in the DOM, whereas in T116269, the browser-native preannotation system inserts a new, confusingly similar element.

It might be fixed if we set "ve.dm.LinkAnnotation.static.inferFromDom = true;" (on top of https://gerrit.wikimedia.org/r/247800/ ) - but I'd rather do that in a separate patch and check the consequences carefully before merging.

Change 257590 had a related patch set uploaded (by Esanders):
LinkAnnotation: Allow inference from DOM

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

Change 257613 had a related patch set uploaded (by Esanders):
WIP Recover annotations via .data('view').

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

Change 257613 merged by jenkins-bot:
TextState: Recover annotation models via .data('view').

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

Esanders claimed this task.

Change 257590 abandoned by Esanders:
LinkAnnotation: Allow inference from DOM

Reason:
Replaced by https://gerrit.wikimedia.org/r/#/c/257613/

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