diff --git a/packages/block-library/src/home-link/edit.js b/packages/block-library/src/home-link/edit.js
index 85571c518c8621..464ccf18d144eb 100644
--- a/packages/block-library/src/home-link/edit.js
+++ b/packages/block-library/src/home-link/edit.js
@@ -56,7 +56,7 @@ export default function HomeEdit( {
return (
<>
-
+
>
);
}
diff --git a/packages/block-library/src/navigation-link/edit.js b/packages/block-library/src/navigation-link/edit.js
index b4efe383aa00c4..50ff5ed4ad2361 100644
--- a/packages/block-library/src/navigation-link/edit.js
+++ b/packages/block-library/src/navigation-link/edit.js
@@ -48,7 +48,7 @@ import { store as coreStore } from '@wordpress/core-data';
import { ItemSubmenuIcon } from './icons';
import { name } from './block.json';
-const ALLOWED_BLOCKS = [ 'core/navigation-link', 'core/spacer' ];
+const ALLOWED_BLOCKS = [ 'core/navigation-link' ];
const MAX_NESTING = 5;
@@ -419,7 +419,6 @@ export default function NavigationLinkEdit( {
hasDescendants
? InnerBlocks.DefaultAppender
: false,
- __experimentalAppenderTagName: 'li',
}
);
@@ -508,7 +507,7 @@ export default function NavigationLinkEdit( {
/>
-
+
);
}
diff --git a/packages/block-library/src/navigation/edit.js b/packages/block-library/src/navigation/edit.js
index d4b6cd57b497b5..0e0e0ab021ce5b 100644
--- a/packages/block-library/src/navigation/edit.js
+++ b/packages/block-library/src/navigation/edit.js
@@ -174,7 +174,7 @@ function Navigation( {
isOpen={ isResponsiveMenuOpen }
isResponsive={ attributes.isResponsive }
>
-
+
>
diff --git a/packages/block-library/src/navigation/index.php b/packages/block-library/src/navigation/index.php
index d4bf579a5b0047..65600551763e88 100644
--- a/packages/block-library/src/navigation/index.php
+++ b/packages/block-library/src/navigation/index.php
@@ -176,7 +176,16 @@ function render_block_core_navigation( $attributes, $content, $block ) {
);
$inner_blocks_html = '';
+ $is_list_open = false;
foreach ( $block->inner_blocks as $inner_block ) {
+ if ( ( 'core/navigation-link' === $inner_block->name || 'core/home-link' === $inner_block->name ) && false === $is_list_open ) {
+ $is_list_open = true;
+ $inner_blocks_html .= '';
+ }
+ if ( 'core/navigation-link' !== $inner_block->name && 'core/home-link' !== $inner_block->name && true === $is_list_open ) {
+ $is_list_open = false;
+ $inner_blocks_html .= '
';
+ }
$inner_blocks_html .= $inner_block->render();
}
@@ -195,7 +204,7 @@ function render_block_core_navigation( $attributes, $content, $block ) {
// return early if they don't.
if ( ! isset( $attributes['isResponsive'] ) || false === $attributes['isResponsive'] ) {
return sprintf(
- '',
+ '',
$wrapper_attributes,
$inner_blocks_html
);
@@ -208,7 +217,7 @@ function render_block_core_navigation( $attributes, $content, $block ) {
diff --git a/packages/block-library/src/navigation/style.scss b/packages/block-library/src/navigation/style.scss
index 4a5ae3b06c55c6..60b939799bb825 100644
--- a/packages/block-library/src/navigation/style.scss
+++ b/packages/block-library/src/navigation/style.scss
@@ -6,6 +6,17 @@
.wp-block-navigation {
position: relative;
+ // Horizontal layout
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+
+ // Vertical layout
+ &.is-vertical {
+ flex-direction: column;
+ align-items: flex-start;
+ }
+
// Normalize list styles.
ul,
ul li {
diff --git a/packages/e2e-tests/specs/experiments/blocks/navigation.test.js b/packages/e2e-tests/specs/experiments/blocks/navigation.test.js
index 4c389d1076970f..d5290e710d3fb7 100644
--- a/packages/e2e-tests/specs/experiments/blocks/navigation.test.js
+++ b/packages/e2e-tests/specs/experiments/blocks/navigation.test.js
@@ -348,7 +348,7 @@ describe( 'Navigation', () => {
// Scope element selector to the Editor's "Content" region as otherwise it picks up on
// block previews.
const navBlockItemsLength = await page.$$eval(
- '[aria-label="Editor content"][role="region"] li[aria-label="Block: Custom Link"]',
+ '[aria-label="Editor content"][role="region"] div[aria-label="Block: Custom Link"]',
( els ) => els.length
);
diff --git a/packages/e2e-tests/specs/experiments/navigation-editor.test.js b/packages/e2e-tests/specs/experiments/navigation-editor.test.js
index 301bbae01c705d..fa8bdf21d852ac 100644
--- a/packages/e2e-tests/specs/experiments/navigation-editor.test.js
+++ b/packages/e2e-tests/specs/experiments/navigation-editor.test.js
@@ -313,7 +313,7 @@ describe( 'Navigation editor', () => {
// Select a link block with nested links in a submenu.
const parentLinkXPath =
- '//li[@aria-label="Block: Custom Link" and contains(.,"WordPress.org")]';
+ '//div[@aria-label="Block: Custom Link" and contains(.,"WordPress.org")]';
const linkBlock = await page.waitForXPath( parentLinkXPath );
await linkBlock.click();
@@ -322,7 +322,7 @@ describe( 'Navigation editor', () => {
// Submenus are hidden using `visibility: hidden` and shown using
// `visibility: visible` so the visible/hidden options must be used
// when selecting the elements.
- const submenuLinkXPath = `${ parentLinkXPath }//li[@aria-label="Block: Custom Link"]`;
+ const submenuLinkXPath = `${ parentLinkXPath }//div[@aria-label="Block: Custom Link"]`;
const submenuLinkVisible = await page.waitForXPath( submenuLinkXPath, {
visible: true,
} );