diff --git a/packages/block-library/src/navigation/edit.js b/packages/block-library/src/navigation/edit.js
index 9edc6046f9deea..034e0ba4255d03 100644
--- a/packages/block-library/src/navigation/edit.js
+++ b/packages/block-library/src/navigation/edit.js
@@ -72,29 +72,24 @@ function Navigation( {
clientId
);
- const innerBlocksProps = useInnerBlocksProps(
- {
- className: 'wp-block-navigation__container',
- },
- {
- allowedBlocks: ALLOWED_BLOCKS,
- orientation: attributes.orientation || 'horizontal',
- renderAppender:
- ( isImmediateParentOfSelectedBlock &&
- ! selectedBlockHasDescendants ) ||
- isSelected
- ? InnerBlocks.DefaultAppender
- : false,
- __experimentalAppenderTagName: 'li',
- __experimentalCaptureToolbars: true,
- // Template lock set to false here so that the Nav
- // Block on the experimental menus screen does not
- // inherit templateLock={ 'all' }.
- templateLock: false,
- __experimentalLayout: LAYOUT,
- placeholder: ,
- }
- );
+ const innerBlocksProps = useInnerBlocksProps( blockProps, {
+ allowedBlocks: ALLOWED_BLOCKS,
+ orientation: attributes.orientation || 'horizontal',
+ renderAppender:
+ ( isImmediateParentOfSelectedBlock &&
+ ! selectedBlockHasDescendants ) ||
+ isSelected
+ ? InnerBlocks.DefaultAppender
+ : false,
+ __experimentalAppenderTagName: 'li',
+ __experimentalCaptureToolbars: true,
+ // Template lock set to false here so that the Nav
+ // Block on the experimental menus screen does not
+ // inherit templateLock={ 'all' }.
+ templateLock: false,
+ __experimentalLayout: LAYOUT,
+ placeholder: ,
+ } );
if ( isPlaceholderShown ) {
return (
@@ -145,9 +140,7 @@ function Navigation( {
) }
-
+
>
);
}
diff --git a/packages/block-library/src/navigation/index.php b/packages/block-library/src/navigation/index.php
index b1fe553df3b3fb..7bbd88e31fd4b0 100644
--- a/packages/block-library/src/navigation/index.php
+++ b/packages/block-library/src/navigation/index.php
@@ -135,7 +135,16 @@ function render_block_core_navigation( $attributes, $content, $block ) {
);
$inner_blocks_html = '';
+ $is_list_open = false;
foreach ( $block->inner_blocks as $inner_block ) {
+ if ($inner_block->name === "core/navigation-link" && $is_list_open === false) {
+ $is_list_open = true;
+ $inner_blocks_html .= '
';
+ }
+ if ($inner_block->name !== "core/navigation-link" && $inner_block->name !== "core/spacer" && $is_list_open === true) {
+ $is_list_open = false;
+ $inner_blocks_html .= '
';
+ }
$inner_blocks_html .= $inner_block->render();
}
@@ -149,7 +158,7 @@ function render_block_core_navigation( $attributes, $content, $block ) {
);
return sprintf(
- '',
+ '',
$wrapper_attributes,
$inner_blocks_html
);