-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Hide 'Add block' control in Link UI when Navigation Link block is in contentOnly mode #71213
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
Conversation
|
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. |
|
Size Change: -3 B (0%) Total Size: 1.92 MB
ℹ️ View Unchanged
|
|
Flaky tests detected in a6776a0. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/17427048930
|
andrewserong
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This appears to be testing well for me:
Before
After
Whether this approach should be extended to other blocks in contentOnly mode
If the conditional rendering logic should be moved to a higher level component
I don't mind the check where it is, it keeps things contained for now and could always be moved further up the tree in follow-ups if needed?
| // Check if we're in contentOnly mode | ||
| const blockEditingMode = useBlockEditingMode(); | ||
| const isContentOnlyMode = blockEditingMode === 'contentOnly'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I notice in some of the other blocks we're doing a truthy check for === 'default' when showing controls, rather than an "not contentOnly", e.g. in the post title block. Would that be a better fit here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we just extract a shared hook, useIsContentOnlyMode?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andrewserong I've adjusted. It's probably a better check because it's more about allowing certain functionality only in default editing mode rather than restricting it for contentOnly.
|
I think the thinking is that the Add block is not content where as the plus inserter is. So no. |
7736bdc to
7552fc8
Compare
|
@andrewserong @scruffian What do you think about merging this one? |
andrewserong
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the ping @getdave! I think this will need a rebase to get tests passing, but this LGTM 🚀
… mode - Import useBlockEditingMode hook from @wordpress/block-editor - Check if block is in contentOnly mode using useBlockEditingMode() - Conditionally render LinkUITools only when not in contentOnly mode - Improves UX by hiding non-content UI when appropriate
9e5ea97 to
a6776a0
Compare

What
Fixes navigation link block UX by hiding the 'Add block' control when the block is in contentOnly mode.
Why
When the Navigation Link block is in contentOnly mode (which hides non-content UI), the 'Add block' button should also be hidden to provide a cleaner, more focused editing experience. This prevents users from seeing UI elements that are not relevant in content-only editing mode.
How
useBlockEditingModehook from@wordpress/block-editoruseBlockEditingMode()Testing
Manual Testing Steps
Block.json Testing (Temporary Hack)
IMPORTANT: The following block.json changes are for testing purposes only and should NOT be committed. They are a temporary workaround to allow Navigation block selection in Write Mode while waiting for a definitive solution.
Why This Temporary Hack is Necessary
The Navigation block currently cannot be selected in Write Mode due to block editing mode restrictions. Adding
role: contentto specific attributes allows temporary selection for testing purposes.How to Apply the Temporary Changes
Apply these diffs to your local files for testing (DO NOT COMMIT):
Navigation Block:
Navigation Link Block:
Testing with the Temporary Changes
Screenshots
[Screenshots to be added]
Breaking Changes
None - this is a UX improvement that maintains existing functionality.
Uncertain Elements