From 8bb1399c97316c7db1e57f6f2565ae8d8b763a55 Mon Sep 17 00:00:00 2001 From: David Lynch Date: Tue, 19 Apr 2016 11:34:48 -0500 Subject: [PATCH] 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 --- modules/ve-mw/ui/inspectors/ve.ui.MWLinkNodeInspector.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/ve-mw/ui/inspectors/ve.ui.MWLinkNodeInspector.js b/modules/ve-mw/ui/inspectors/ve.ui.MWLinkNodeInspector.js index 9f9c67cd66..1778ba7701 100644 --- a/modules/ve-mw/ui/inspectors/ve.ui.MWLinkNodeInspector.js +++ b/modules/ve-mw/ui/inspectors/ve.ui.MWLinkNodeInspector.js @@ -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(