-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Description
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
openSubmenusOnClickfrom both attributes andprovidesContext. Replaced withsubmenuVisibility(default: "hover"). - navigation-submenu/block.json: Removed
openSubmenusOnClickfromusesContext. Replaced withsubmenuVisibility. - navigation-submenu.php (PHP render): Added
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 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-clickclass 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.
- Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
- Yes
Please confirm which theme type you used for testing.
- Block
- Classic
- Hybrid (e.g. classic with theme.json)
- Not sure
Metadata
Metadata
Assignees
Labels
Type
Fields
Give feedbackProjects
Status