Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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