-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Add View button to navigation link blocks #70986
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
Size Change: +251 B (+0.01%) Total Size: 1.91 MB
ℹ️ View Unchanged
|
- Move View button implementation from navigation-link block to editor hook - Create navigation-link-view-button.js hook following pattern-overrides.js pattern - Hook targets core/navigation-link and core/navigation-submenu blocks - Use __unstableBlockToolbarLastItem to position button as last item - Remove router dependency issues by using editor hook context - Register hook in editor hooks index
- Replace router-based navigation with editor's onNavigateToEntityRecord - Add conditional focusMode support to onNavigateToEntityRecord - Disable focusMode for View button navigation for better UX - Maintain backwards compatibility for existing usage - Only show View button when block is selected
- Add type === 'page' condition to restrict View button to pages only - Prevents button from appearing on other post types (books, posts, etc.) - Maintains existing behavior for custom links (no button shown)
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. |
Flaky tests detected in 8d53012. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/16644768560
|
What
Adds a "View" button to the block toolbar for navigation link blocks that represent Pages (only). When clicked, the button navigates to the corresponding page in edit mode within the current editor context.
Note this doesn't not support other post types but could be extended to do so in the future if necessary.
Why
This enhancement improves the user experience by allowing quick navigation to pages while maintaining the editing workflow. Users can now easily jump to different pages without losing their current editing context or unsaved changes.
How
onNavigateToEntityRecord
to navigate within the editoronNavigateToEntityRecord Enhancement
The
onNavigateToEntityRecord
function has been enhanced to support conditionalfocusMode
parameter handling:focusMode: true
)focusMode: false
is explicitly passed, the parameter is entirely removed from the URL query stringfocusMode: false
to show the full editor interface rather than just the focused content areaTesting
Screenshots