From 28b539a1ad9f3f3429b7ec4581e28409941213c9 Mon Sep 17 00:00:00 2001 From: Mustaque Ahmed Date: Sat, 10 Sep 2022 16:42:03 +0530 Subject: [PATCH 1/2] 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: https://github.com/WordPress/gutenberg/issues/43470 --- packages/block-library/src/navigation/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/block-library/src/navigation/index.php b/packages/block-library/src/navigation/index.php index 8fa9c9b7332bfa..ee41ed7ab8db34 100644 --- a/packages/block-library/src/navigation/index.php +++ b/packages/block-library/src/navigation/index.php @@ -556,7 +556,7 @@ function render_block_core_navigation( $attributes, $content, $block ) { $is_list_open = false; $inner_blocks_html .= ''; } - if ( 'core/site-title' === $inner_block->name || 'core/site-logo' === $inner_block->name ) { + if ( 'core/site-title' === $inner_block->name || ( 'core/site-logo' === $inner_block->name && $inner_block->render() ) ) { $inner_blocks_html .= '
  • ' . $inner_block->render() . '
  • '; } else { $inner_blocks_html .= $inner_block->render(); From b188a21aa8dca6a999cd8dfc4f592820a3fc3f23 Mon Sep 17 00:00:00 2001 From: Mustaque Ahmed Date: Mon, 12 Sep 2022 20:33:30 +0530 Subject: [PATCH 2/2] introduce temp variable to store inner block content Co-authored-by: Bernie Reiter --- packages/block-library/src/navigation/index.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/block-library/src/navigation/index.php b/packages/block-library/src/navigation/index.php index ee41ed7ab8db34..cb33dd4ba3bb44 100644 --- a/packages/block-library/src/navigation/index.php +++ b/packages/block-library/src/navigation/index.php @@ -556,10 +556,11 @@ function render_block_core_navigation( $attributes, $content, $block ) { $is_list_open = false; $inner_blocks_html .= ''; } - if ( 'core/site-title' === $inner_block->name || ( 'core/site-logo' === $inner_block->name && $inner_block->render() ) ) { - $inner_blocks_html .= '
  • ' . $inner_block->render() . '
  • '; + $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 .= '
  • ' . $inner_block_content . '
  • '; } else { - $inner_blocks_html .= $inner_block->render(); + $inner_blocks_html .= $inner_block_content; } }