-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Navigation Block: Make selectable in Write Mode #70977
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Conversation
This change makes navigation menu item labels editable in Write Mode by adding role: 'content' to the label attribute for both core/navigation-link and core/navigation-submenu blocks. This allows users to: - Edit menu item text/labels in Write Mode - Maintain the content-focused editing experience - Keep layout and styling controls disabled in Write Mode Part of the Navigation Block Write Mode improvements.
This change treats Navigation blocks like Template Parts in Write Mode by giving them 'contentOnly' editing mode when outside of sections. This allows Navigation blocks to be selectable and editable in Write Mode while maintaining the content-focused editing experience, similar to how Template Parts work.
This change prevents navigation blocks from showing their child blocks in the content panel of the inspector, since navigation menu items should be edited directly in the canvas rather than through the inspector.
This change improves performance by removing the expensive getBlocksByName() call and using direct block name comparison instead of array operations. The logic now checks if a block is within a navigation context more efficiently.
Remove custom Navigation block logic from reducer and rely on content role attribute instead. This is a cleaner approach that uses the existing Write Mode infrastructure. - Remove custom Navigation block handling from getDerivedBlockEditingModesForTree - Add role: 'content' to the ref attribute in Navigation block.json - Remove debug logging Now Navigation blocks are selectable in Write Mode because they have content role attributes, following the same pattern as other content blocks.
Size Change: +33 B (0%) Total Size: 1.91 MB
ℹ️ View Unchanged
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
What
Fixes part of #65699: Make Navigation blocks selectable in Write Mode by adding content role attributes to navigation menu item labels.
This change allows users to edit navigation menu item text/labels directly in the canvas when in Write Mode, while maintaining the content-focused editing experience.
Why
Currently, Navigation blocks are not selectable in Write Mode because they lack the required attributes that Write Mode uses to determine which blocks are editable. This prevents users from editing navigation menu content when in Write Mode.
How
Testing
Screenshots
Screen.Capture.on.2025-07-30.at.12-07-19.mp4
Notes
This addresses part of the UX described in #65699 but does not implement the full inspector-based menu editing experience outlined in #65699 (comment). The current implementation focuses on making navigation menu items directly editable in the canvas, which aligns with Write Mode's content-focused philosophy.