Skip to content

Commit

Permalink
Mobile - Fix link selection when a zero width space is selected (#28747)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerardo Pacheco authored Feb 9, 2021
1 parent 223b5ea commit 85d74aa
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,15 @@ const LinkSettingsScreen = ( {
// transform selected text into link
newAttributes = applyFormat( value, format );
}
//move selection to end of link
newAttributes.start = newAttributes.end;
// move selection to end of link
const textLength = newAttributes.text.length;
// check for zero width spaces
if ( newAttributes.end > textLength ) {
newAttributes.start = textLength;
newAttributes.end = textLength;
} else {
newAttributes.start = newAttributes.end;
}
newAttributes.activeFormats = [];
onChange( { ...newAttributes, needsSelectionUpdate: true } );
if ( ! isValidHref( url ) ) {
Expand Down

0 comments on commit 85d74aa

Please sign in to comment.