Skip to content

Commit

Permalink
navigation block: fix empty site-log li element in the dom (#44049)
Browse files Browse the repository at this point in the history
* navigation block: fix empty site-log `li` element in the dom

An empty check is added if `core/site-logo` is non-empty then add a
`li` element in the dom or else it will continue rest of the statements.
Fixes: #43470

* introduce temp variable to store inner block content

Co-authored-by: Bernie Reiter <[email protected]>

Co-authored-by: Bernie Reiter <[email protected]>
  • Loading branch information
amustaque97 and ockham authored Sep 12, 2022
1 parent 9ccd2d3 commit 559b191
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/block-library/src/navigation/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -556,10 +556,11 @@ function render_block_core_navigation( $attributes, $content, $block ) {
$is_list_open = false;
$inner_blocks_html .= '</ul>';
}
if ( 'core/site-title' === $inner_block->name || 'core/site-logo' === $inner_block->name ) {
$inner_blocks_html .= '<li class="wp-block-navigation-item">' . $inner_block->render() . '</li>';
$inner_block_content = $inner_block->render();
if ( 'core/site-title' === $inner_block->name || ( 'core/site-logo' === $inner_block->name && $inner_block_content ) ) {
$inner_blocks_html .= '<li class="wp-block-navigation-item">' . $inner_block_content . '</li>';
} else {
$inner_blocks_html .= $inner_block->render();
$inner_blocks_html .= $inner_block_content;
}
}

Expand Down

0 comments on commit 559b191

Please sign in to comment.