From 513ff939978f1c4eba9ee11c1e99c3b2a25e9a8e Mon Sep 17 00:00:00 2001 From: Vicente Canales <1157901+vcanales@users.noreply.github.com> Date: Fri, 26 Nov 2021 12:59:45 -0300 Subject: [PATCH] Only show submenu options and Show arrow button when relevant. (#36826) * only show submenu options when relevant * disable show arrow button when open on click on * rename found submenus variable --- .../src/navigation/edit/index.js | 59 ++++++++++++------- 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/packages/block-library/src/navigation/edit/index.js b/packages/block-library/src/navigation/edit/index.js index 90fa24172d0834..c27bccadc69cb9 100644 --- a/packages/block-library/src/navigation/edit/index.js +++ b/packages/block-library/src/navigation/edit/index.js @@ -134,13 +134,19 @@ function Navigation( { `navigationMenu/${ ref }` ); - const { innerBlocks, isInnerBlockSelected } = useSelect( + const { innerBlocks, isInnerBlockSelected, hasSubmenus } = useSelect( ( select ) => { const { getBlocks, hasSelectedInnerBlock } = select( blockEditorStore ); + const blocks = getBlocks( clientId ); + const firstSubmenu = !! blocks.find( + ( block ) => block.name === 'core/navigation-submenu' + ); + return { - innerBlocks: getBlocks( clientId ), + hasSubmenus: firstSubmenu, + innerBlocks: blocks, isInnerBlockSelected: hasSelectedInnerBlock( clientId, true ), }; }, @@ -411,26 +417,35 @@ function Navigation( { label={ __( 'Always' ) } /> -