Skip to content

Commit

Permalink
Enable backspace to remove empty Navigation Links.
Browse files Browse the repository at this point in the history
  • Loading branch information
ZebulanStanphill committed May 1, 2020
1 parent f9f6e1c commit bb599bb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 4 additions & 0 deletions packages/block-library/src/navigation-link/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ function NavigationLinkEdit( {
rgbBackgroundColor,
saveEntityRecord,
userCanCreatePages = false,
mergeBlocks,
onReplace,
} ) {
const { label, opensInNewTab, url, nofollow, description } = attributes;
const link = {
Expand Down Expand Up @@ -217,6 +219,8 @@ function NavigationLinkEdit( {
onChange={ ( labelValue ) =>
setAttributes( { label: labelValue } )
}
onMerge={ mergeBlocks }
onRemove={ () => onReplace( [] ) }
placeholder={ itemLabelPlaceholder }
keepPlaceholderOnFocus
withoutInteractiveFormatting
Expand Down
13 changes: 7 additions & 6 deletions packages/block-library/src/navigation-link/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

0 comments on commit bb599bb

Please sign in to comment.