Skip to content

Commit

Permalink
Navigation Submenu Block: Make block name affect list view (#58296)
Browse files Browse the repository at this point in the history
* Navigation Submenu Block: Make block name affect list view

* Fix e2e test
  • Loading branch information
t-hamano authored Jan 26, 2024
1 parent 11a9943 commit a241134
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/block-library/src/navigation-submenu/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,23 @@ export const settings = {
if ( context === 'list-view' ) {
return page;
}

return addSubmenu;
},
__experimentalLabel( attributes, { context } ) {
const { label } = attributes;

__experimentalLabel: ( { label } ) => label,
const customName = attributes?.metadata?.name;

edit,
// In the list view, use the block's menu label as the label.
// If the menu label is empty, fall back to the default label.
if ( context === 'list-view' && ( customName || label ) ) {
return attributes?.metadata?.name || label;
}

return label;
},
edit,
save,

transforms,
};

Expand Down

0 comments on commit a241134

Please sign in to comment.