Page MenuHomePhabricator

Add a link in VE: issues with opening context when selection is at the edges of an annotation
Closed, ResolvedPublic

Description

When navigating to a suggested link, we would like to drop a cursor (i.e. a zero-length selection( at the start of the suggested link annotation. However, because link annotations are nailed, it's ambiguous whether the context should be open in that case (because there's are two CE cursor positions, one outside and one inside the link, but they're the same cursor position in the DM). For a zero-length selection at the start of the annotation, the context doesn't open, and we can't force it to open either.

To work around this, we select the entire annotation. This is also ambiguous (because both ends of the selection could be outside the link), and the context still doesn't open on its own, but we can force it to with this.context.getSurface().getView().updateActiveAnnotations( true ).

This works when navigating to a different annotation, but not when replacing the annotation under the cursor (which happens when the user clicks the "yes" or "no" buttons to mark the suggestion as accepted/rejected). Because that causes a rerender, calling updateActiveAnnotations() doesn't work because that happens too early, and wrapping it in a setTimeout doesn't work either.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Can this be fixed using ve.ce.Surface#selectAnnotation?

Catrope claimed this task.

Can this be fixed using ve.ce.Surface#selectAnnotation?

Yes, thank you so much for pointing this out! That function does select the entire annotation, but other than that it achieves what I wanted.