diff --git a/packages/format-library/src/link/index.native.js b/packages/format-library/src/link/index.native.js index a1015cf9179f8..3b2adb8b6e8c5 100644 --- a/packages/format-library/src/link/index.native.js +++ b/packages/format-library/src/link/index.native.js @@ -59,12 +59,13 @@ export const link = { const text = getTextContent( slice( value ) ); if ( text && isURL( text ) ) { - onChange( - applyFormat( value, { - type: name, - attributes: { url: text }, - } ) - ); + const newValue = applyFormat( value, { + type: name, + attributes: { url: text }, + } ); + newValue.start = newValue.end; + newValue.activeFormats = []; + onChange( { ...newValue, needsSelectionUpdate: true } ); } else { this.setState( { addingLink: true } ); this.getURLFromClipboard(); diff --git a/packages/format-library/src/link/modal.native.js b/packages/format-library/src/link/modal.native.js index d288b69262a59..f2edc774da53f 100644 --- a/packages/format-library/src/link/modal.native.js +++ b/packages/format-library/src/link/modal.native.js @@ -87,7 +87,7 @@ class ModalLinkUI extends Component { opensInNewWindow, text: linkText, } ); - + let newAttributes; if ( isCollapsed( value ) && ! isActive ) { // insert link const toInsert = applyFormat( @@ -96,8 +96,7 @@ class ModalLinkUI extends Component { 0, linkText.length ); - const newAttributes = insert( value, toInsert ); - onChange( { ...newAttributes, needsSelectionUpdate: true } ); + newAttributes = insert( value, toInsert ); } else if ( text !== getTextContent( slice( value ) ) ) { // edit text in selected link const toInsert = applyFormat( @@ -106,18 +105,15 @@ class ModalLinkUI extends Component { 0, text.length ); - const newAttributes = insert( - value, - toInsert, - value.start, - value.end - ); - onChange( { ...newAttributes, needsSelectionUpdate: true } ); + newAttributes = insert( value, toInsert, value.start, value.end ); } else { // transform selected text into link - const newAttributes = applyFormat( value, format ); - onChange( { ...newAttributes, needsSelectionUpdate: true } ); + newAttributes = applyFormat( value, format ); } + //move selection to end of link + newAttributes.start = newAttributes.end; + newAttributes.activeFormats = []; + onChange( { ...newAttributes, needsSelectionUpdate: true } ); if ( ! isValidHref( url ) ) { speak(