From cf8e9f665fea22db7bf693be1a72bc2a518c036a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Est=C3=AAv=C3=A3o?= Date: Mon, 30 Sep 2019 13:39:42 +0100 Subject: [PATCH] Rnmobile/fix link editing on start (#17631) * Don't try to clear links if text is clean. * Commented LinkUI removal test when no URL. * Don't try to remove link if we are at start of link and no actual selection is --- packages/format-library/src/link/index.native.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/format-library/src/link/index.native.js b/packages/format-library/src/link/index.native.js index 8457682d07d28..c9640b62de77b 100644 --- a/packages/format-library/src/link/index.native.js +++ b/packages/format-library/src/link/index.native.js @@ -94,7 +94,15 @@ export const link = { } onRemoveFormat() { - const { onChange, speak } = this.props; + const { onChange, speak, value } = this.props; + const startFormat = getActiveFormat( value, 'core/link' ); + + // If the previous position from start doesn't have the link is because we are at the start + const linkStart = ! find( value.formats[ value.start - 1 ], startFormat ); + if ( linkStart && isCollapsed( value ) ) { + return; + } + const linkSelection = this.getLinkSelection(); onChange( removeFormat( linkSelection, name ) );