From 8597fc6ba8afc7bb10789750bf60dc2228bb82e7 Mon Sep 17 00:00:00 2001 From: Tetsuaki Hamano Date: Fri, 26 Jan 2024 15:10:52 +0900 Subject: [PATCH 1/2] Navigation Submenu Block: Make block name affect list view --- .../block-library/src/navigation-submenu/index.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/block-library/src/navigation-submenu/index.js b/packages/block-library/src/navigation-submenu/index.js index 2b3691b6e3cad..995f32cd882a2 100644 --- a/packages/block-library/src/navigation-submenu/index.js +++ b/packages/block-library/src/navigation-submenu/index.js @@ -21,16 +21,21 @@ 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; + // 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; + } + }, edit, - save, - transforms, }; From 156e8ba027e8fa513c9e05f4ea01cb533194587f Mon Sep 17 00:00:00 2001 From: Tetsuaki Hamano Date: Fri, 26 Jan 2024 18:21:20 +0900 Subject: [PATCH 2/2] Fix e2e test --- packages/block-library/src/navigation-submenu/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/block-library/src/navigation-submenu/index.js b/packages/block-library/src/navigation-submenu/index.js index 995f32cd882a2..69e97fb85325a 100644 --- a/packages/block-library/src/navigation-submenu/index.js +++ b/packages/block-library/src/navigation-submenu/index.js @@ -33,6 +33,8 @@ export const settings = { if ( context === 'list-view' && ( customName || label ) ) { return attributes?.metadata?.name || label; } + + return label; }, edit, save,