Skip to content

Navigation block: Migration from openSubmenusOnClick to submenuVisibility breaks existing blocks that had "Open on click" enabled #75409

@Ninodevo

Description

@Ninodevo

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

  1. On a site running WP 6.9.x without the Gutenberg plugin, create a Navigation block with submenu items
  2. Enable "Open on click" in the block settings (this saves openSubmenusOnClick: true on the block)
  3. Verify the frontend renders with open-on-click class and the submenu label as a <button>
  4. Activate the Gutenberg plugin (22.5+)
  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

No one assigned

    Labels

    [Block] NavigationAffects the Navigation Block[Block] SubmenuAffects the Submenu Block - for submenus in navigation[Type] BugAn existing feature does not function as intended

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions