Skip to content

Commit

Permalink
Check for isActive before opening popover on link click
Browse files Browse the repository at this point in the history
  • Loading branch information
jeryj committed Jan 24, 2024
1 parent b7ba204 commit ec501ea
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/format-library/src/link/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@ function Edit( {
}

function handleClick( event ) {
if ( event.target.tagName !== 'A' ) {
// There is a situation whereby there is an existing link in the rich text
// and the user clicks on the leftmost edge of that link and fails to activate
// the link format, but the click event still fires on the `<a>` element.
// This causes the `addingLink` state to be set to `true` and the link UI
// to be rendered in "creating" mode. We need to check isActive to see if
// we have an active link format.
if ( event.target.tagName !== 'A' || ! isActive ) {
return;
}
setAddingLink( true );
Expand Down

0 comments on commit ec501ea

Please sign in to comment.