Skip to content

Commit

Permalink
Unable Unlink UI to allow users to remove existing links (#33777)
Browse files Browse the repository at this point in the history
  • Loading branch information
getdave authored Aug 3, 2021
1 parent b42cd74 commit 52970e7
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions packages/block-library/src/navigation-link/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,23 @@ export default function NavigationLinkEdit( {
selection.addRange( range );
}

/**
* Removes the current link if set.
*/
function removeLink() {
// Reset all attributes that comprise the link.
setAttributes( {
url: '',
label: '',
id: '',
kind: '',
type: '',
} );

// Close the link editing UI.
setIsLinkOpen( false );
}

let userCanCreate = false;
if ( ! type || type === 'page' ) {
userCanCreate = userCanCreatePages;
Expand Down Expand Up @@ -690,6 +707,7 @@ export default function NavigationLinkEdit( {
attributes
)
}
onRemove={ removeLink }
/>
</Popover>
) }
Expand Down

0 comments on commit 52970e7

Please sign in to comment.