Description
PR #74653 (Gutenberg 22.5) migrated the openSubmenusOnClick boolean attribute to a new submenuVisibility string enum attribute on the Navigation block. However, this migration has a backward-compatibility regression: existing Navigation blocks saved with openSubmenusOnClick: true silently revert to hover mode on the frontend.
Root cause
- navigation/block.json: Removed
openSubmenusOnClick from both attributes and providesContext. Replaced with submenuVisibility (default: "hover").
- navigation-submenu/block.json: Removed
openSubmenusOnClick from usesContext. Replaced with submenuVisibility.
- navigation-submenu.php (PHP render): Added
gutenberg_block_core_navigation_submenu_get_submenu_visibility() which has backward-compat logic to check both submenuVisibility and openSubmenusOnClick in the block context.
The problem is that step 3's backward-compat function can never receive openSubmenusOnClick via $block->context, because steps 1 and 2 removed it from the providesContext/usesContext pipeline. Even though the attribute value openSubmenusOnClick: true is still stored in the wp_navigation post content, it is never passed down to child blocks.
Step-by-step reproduction instructions
- On a site running WP 6.9.x without the Gutenberg plugin, create a Navigation block with submenu items
- Enable "Open on click" in the block settings (this saves openSubmenusOnClick: true on the block)
- Verify the frontend renders with
open-on-click class and the submenu label as a <button>
- Activate the Gutenberg plugin (22.5+)
- Without editing the Navigation block at all, visit the frontend again
Expected behavior
The submenu should still render in click mode (open-on-click class), respecting the saved openSubmenusOnClick: true attribute.
Actual behavior
The submenu renders in hover mode (open-on-hover-click class). The <button> label becomes an <a> link, and the <span class="wp-block-navigation__submenu-icon"> wrapping the SVG chevron is replaced with a <button>.
Screenshots, screen recording, code snippet
No response
Environment info
WordPress: 6.9.1
Gutenberg plugin: 22.5.1
Please confirm that you have searched existing issues in the repo.
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Please confirm which theme type you used for testing.
Description
PR #74653 (Gutenberg 22.5) migrated the
openSubmenusOnClickboolean attribute to a newsubmenuVisibilitystring enum attribute on the Navigation block. However, this migration has a backward-compatibility regression: existing Navigation blocks saved withopenSubmenusOnClick: truesilently revert to hover mode on the frontend.Root cause
openSubmenusOnClickfrom both attributes andprovidesContext. Replaced withsubmenuVisibility(default: "hover").openSubmenusOnClickfromusesContext. Replaced withsubmenuVisibility.gutenberg_block_core_navigation_submenu_get_submenu_visibility()which has backward-compat logic to check bothsubmenuVisibilityandopenSubmenusOnClickin the block context.The problem is that step 3's backward-compat function can never receive
openSubmenusOnClickvia$block->context, because steps 1 and 2 removed it from theprovidesContext/usesContextpipeline. Even though the attribute valueopenSubmenusOnClick: trueis still stored in thewp_navigationpost content, it is never passed down to child blocks.Step-by-step reproduction instructions
open-on-clickclass and the submenu label as a<button>Expected behavior
The submenu should still render in click mode (
open-on-clickclass), respecting the savedopenSubmenusOnClick: trueattribute.Actual behavior
The submenu renders in hover mode (
open-on-hover-clickclass). The<button>label becomes an<a>link, and the<span class="wp-block-navigation__submenu-icon">wrapping the SVG chevron is replaced with a<button>.Screenshots, screen recording, code snippet
No response
Environment info
WordPress: 6.9.1
Gutenberg plugin: 22.5.1
Please confirm that you have searched existing issues in the repo.
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Please confirm which theme type you used for testing.