Select the label properly when converting LinkNode to LinkAnnotation

We were selecting outside the annotation, when converting a LinkNode to a
LinkAnnotation. This meant that typing would overwrite the annotation as well
as the label. Speculatively, this is probably a side-effect of recent changes
to how nails and cursor offsets interact.

Bug: T121448
Change-Id: Ib2274bc5857294c5b691b3c3567b135d68bfa596
Depends-On: I3954c7f8f8e5870b13a8f6c4f0e86fb3b20b3cd3
This commit is contained in:
David Lynch 2016-04-19 11:34:48 -05:00
parent 7f9ab36d6a
commit 8bb1399c97

View file

@ -143,7 +143,12 @@ ve.ui.MWLinkNodeInspector.prototype.getTeardownProcess = function ( data ) {
// selection starts inside or outside of the node.
// If you can think of a test function for "the selection has stabilised", this could
// be moved to ve.scheduler.
surfaceView.selectActiveLinkContents();
// Note: we can't rely on surfaceView.activeLink, because the selection-focus created
// by the transaction might be outside the link node. As such, get the node immediately
// after the offset where we inserted the annotation, and then get the closest link
// annotation to it.
var node = surfaceView.getDocument().getNodeAndOffset( nodeRange.start + 1 ).node;
surfaceView.selectNodeContents( $( node ).closest( '.ve-ce-linkAnnotation' )[ 0 ] );
} );
} else {
surfaceModel.change(