diff --git a/packages/block-library/src/navigation-link/edit.js b/packages/block-library/src/navigation-link/edit.js index f390210bf19330..e22f9b0d0f28e4 100644 --- a/packages/block-library/src/navigation-link/edit.js +++ b/packages/block-library/src/navigation-link/edit.js @@ -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; @@ -690,6 +707,7 @@ export default function NavigationLinkEdit( { attributes ) } + onRemove={ removeLink } /> ) }