Skip to content

The future of the block-nav-menus theme opt-in for the Navigation Screen #33969

@talldan

Description

@talldan

#24503 introduced the concept of the theme opt-in to the navigation screen.

This opt-in is a way for the theme to declare that it supports styles for a wider range of blocks in a menu. Once this is active, more block types are supported by the navigation screen. In the front-end, menus are rendered using the block markup, instead of the markup produced by the core wp_nav_menu function.

Since most of the development has been based around building a good foundation for the navigation screen, the feature hasn't had much focus. There are several aspects that could be improved.

Improvements

Saving menus

When the theme opt-in is active, the navigation screen still coverts blocks into the old menu item format when saving. This has a few consequences:

  • None of the more advanced features of the navigation block itself are supported (e.g. colours, submenu indicators, spacing), since this information can't be saved
  • It's possible for a user to go back to the old menu screen and re-arrange blocks into an invalid structure (e.g. a link as a child of a search block)
  • The code for rendering menus is much more complicated, and involves hooking into wp_nav_menu and converting menus to blocks

Possible solution: investigate options for saving the entire navigation block in its usual HTML format when the theme opt-in is active.

edit: This could incorporate the editor using the same storage for the block as outlined in #34612 (template part / custom post type).

Visual editing and theme styles

By default the navigation editor has an accordion style appearance, which is somewhat different to the usual appearance of the navigation block.

When a theme has opted-in, it should be possible for the user to achieve anything with their menu that they could achieve in the post or site editor. The user should be able to edit a menu that's a more accurate representation of the front-end of their site.

Furthermore, it could also be possible for themes to provide editor styles for menu locations.

Migrating between themes

Whatever approach is taken, users should be able to migrate menus between themes that may or may not have the theme opt-in.

The immediate future

The navigation editor is approaching a reasonable level of stability, and it'd be good to consider removing the experimental flag in the Gutenberg plugin, or making it opt-out instead of opt-in. Given the theme opt-in still needs a fair amount of work, it could be an idea to consider making this part of the screen experimental while it's being developed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Type] DiscussionFor issues that are high-level and not yet ready to implement.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions