From a24113433aa3c64670095ba0721a24354910b9d7 Mon Sep 17 00:00:00 2001 From: Aki Hamano <54422211+t-hamano@users.noreply.github.com> Date: Fri, 26 Jan 2024 18:57:42 +0900 Subject: [PATCH] Navigation Submenu Block: Make block name affect list view (#58296) * Navigation Submenu Block: Make block name affect list view * Fix e2e test --- .../block-library/src/navigation-submenu/index.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/block-library/src/navigation-submenu/index.js b/packages/block-library/src/navigation-submenu/index.js index 2b3691b6e3cada..69e97fb85325a5 100644 --- a/packages/block-library/src/navigation-submenu/index.js +++ b/packages/block-library/src/navigation-submenu/index.js @@ -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, };