Skip to content

Commit

Permalink
Change markup on front end
Browse files Browse the repository at this point in the history
  • Loading branch information
tellthemachines committed May 28, 2021
1 parent e4a2ea5 commit bdc5dab
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 27 deletions.
47 changes: 20 additions & 27 deletions packages/block-library/src/navigation/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,29 +78,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: <PlaceholderPreview />,
}
);
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: <PlaceholderPreview />,
} );

if ( isPlaceholderShown ) {
return (
Expand Down Expand Up @@ -166,15 +161,13 @@ function Navigation( {
</PanelBody>
) }
</InspectorControls>
<nav { ...blockProps }>
<nav { ...innerBlocksProps }>
<ResponsiveWrapper
id={ clientId }
onToggle={ setResponsiveMenuVisibility }
isOpen={ isResponsiveMenuOpen }
isResponsive={ attributes.isResponsive }
>
<ul { ...innerBlocksProps }></ul>
</ResponsiveWrapper>
></ResponsiveWrapper>
</nav>
</>
);
Expand Down
9 changes: 9 additions & 0 deletions packages/block-library/src/navigation/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,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 .= '<ul class="wp-block-navigation__container">';
}
if ($inner_block->name !== "core/navigation-link" && $inner_block->name !== "core/spacer" && $is_list_open === true) {
$is_list_open = false;
$inner_blocks_html .= '</ul>';
}
$inner_blocks_html .= $inner_block->render();
}

Expand Down

0 comments on commit bdc5dab

Please sign in to comment.