From bb599bb02ba287bfe3cb72b068764c565627e4d5 Mon Sep 17 00:00:00 2001 From: Zebulan Stanphill Date: Fri, 1 May 2020 11:55:07 -0500 Subject: [PATCH] Enable backspace to remove empty Navigation Links. --- packages/block-library/src/navigation-link/edit.js | 4 ++++ packages/block-library/src/navigation-link/index.js | 13 +++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/packages/block-library/src/navigation-link/edit.js b/packages/block-library/src/navigation-link/edit.js index 60ebdb45a68c7a..390f2e2dcb9fbc 100644 --- a/packages/block-library/src/navigation-link/edit.js +++ b/packages/block-library/src/navigation-link/edit.js @@ -54,6 +54,8 @@ function NavigationLinkEdit( { rgbBackgroundColor, saveEntityRecord, userCanCreatePages = false, + mergeBlocks, + onReplace, } ) { const { label, opensInNewTab, url, nofollow, description } = attributes; const link = { @@ -217,6 +219,8 @@ function NavigationLinkEdit( { onChange={ ( labelValue ) => setAttributes( { label: labelValue } ) } + onMerge={ mergeBlocks } + onRemove={ () => onReplace( [] ) } placeholder={ itemLabelPlaceholder } keepPlaceholderOnFocus withoutInteractiveFormatting diff --git a/packages/block-library/src/navigation-link/index.js b/packages/block-library/src/navigation-link/index.js index 57c01fc50ad76b..092154a3731818 100644 --- a/packages/block-library/src/navigation-link/index.js +++ b/packages/block-library/src/navigation-link/index.js @@ -12,25 +12,26 @@ import edit from './edit'; import save from './save'; const { name } = metadata; + export { metadata, name }; export const settings = { title: __( 'Navigation Link' ), - parent: [ 'core/navigation' ], - icon, - description: __( 'Add a page, link, or another item to your navigation.' ), - supports: { reusable: false, html: false, lightBlockWrapper: true, }, - __experimentalLabel: ( { label } ) => label, - + merge( attributes, attributesToMerge ) { + return { + label: + ( attributes.label || '' ) + ( attributesToMerge.label || '' ), + }; + }, edit, save, };