You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Navigation block: Hiding a link item breaks the HTML into two separate lists #78784
I hid one of the links inside the navigation block, and on the frontend it shows two <ul> elements, one with all menu items up to the hidden link, and the next with all items after the hidden link. This affects styling.
I noticed it on our site because our menu uses CSS multi-column layout, and the menu items after the hidden item were below on their own line instead of in the usual flow.
Step-by-step reproduction instructions
Add navigation block.
Add several items to navigation block.
Use the new block visibility feature to hide one of the items.
View frontend and see menu has two <ul>s now.
Screenshots, screen recording, code snippet
No response
Environment info
WordPress 7.0
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
Please confirm which theme type you used for testing.
I can reproduce this on WordPress 7.0 with Gutenberg active.
Hiding a middle navigation item results in two separate <ul class="wp-block-navigation__container">
elements in the DOM one containing items before the hidden block,
one containing items after it.
Looking into the Navigation block's render logic for a fix.
In WP_Navigation_Block_Renderer::get_inner_blocks_html(), the loop tracks list state using an $is_list_open flag. When a block is hidden via block visibility, $inner_block->render() returns an empty string ''. WP_HTML_Tag_Processor finds no <li> in the empty string, so $is_list_item is false. This satisfies the close condition ! $is_list_item && $is_list_open, closing the <ul> prematurely. The next visible item then opens a brand new <ul>, producing two separate lists.
Fix: Added an early continue to skip empty block markup inside the foreach loop, preserving the $is_list_open state across hidden blocks:
Activity
vedant-ere commentedon May 29, 2026
I can reproduce this on WordPress 7.0 with Gutenberg active.
Hiding a middle navigation item results in two separate
<ul class="wp-block-navigation__container">elements in the DOM one containing items before the hidden block,
one containing items after it.
Looking into the Navigation block's render logic for a fix.
vedant-ere commentedon May 29, 2026
Root cause identified:
In
WP_Navigation_Block_Renderer::get_inner_blocks_html(), the loop tracks list state using an$is_list_openflag. When a block is hidden via block visibility,$inner_block->render()returns an empty string''.WP_HTML_Tag_Processorfinds no<li>in the empty string, so$is_list_itemisfalse. This satisfies the close condition! $is_list_item && $is_list_open, closing the<ul>prematurely. The next visible item then opens a brand new<ul>, producing two separate lists.Fix: Added an early
continueto skip empty block markup inside theforeachloop, preserving the$is_list_openstate across hidden blocks:PR attached in #78793.