-
Couldn't load subscription status.
- Fork 4.6k
Block API: Add block visibility control in the command center #72154
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
- Added support for toggling block visibility based on block attributes. - Introduced new commands to show/hide selected blocks with appropriate labels. - Utilized existing utility functions to clean up metadata before updating block attributes. This update improves the user experience by allowing users to manage block visibility directly from the block commands.
| name: 'core/toggle-block-visibility', | ||
| label: blockVisibilityLabel, | ||
| callback: () => { | ||
| const attributesByClientId = Object.fromEntries( |
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.
A lot of this is copied over from:
Is there scope for centralization, e.g., a private action?
| const canToggleBlockVisibility = blocks.every( ( { clientId } ) => | ||
| hasBlockSupport( getBlockName( clientId ), 'blockVisibility', true ) | ||
| ); |
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'm not sure if these should use useMemo - other, similar array filters don't in this file 🤔
|
Thanks for working on this PR 🙏 I've only had a quick look at it, but I think "Show" and "Hide" will probably be enough, since that's the case with the other block actions as well.
|
Ah, do you mean the label? No problem. And thanks for the very fast feedback!! 🙇🏻 |
|
Size Change: +65 B (0%) Total Size: 1.96 MB
ℹ️ View Unchanged
|
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.
LGTM!
packages/block-editor/src/components/use-block-commands/index.js
Outdated
Show resolved
Hide resolved
|
Flaky tests detected in a610286. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/18338236849
|
Co-authored-by: Aki Hamano <[email protected]>
|
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. |
…ess#72154) Co-authored-by: ramonjd <[email protected]> Co-authored-by: t-hamano <[email protected]>
What?
Follow up to #71203
Part of
This PR adds support for toggling block visibility based on block attributes in the command centre.
Why?
To make the show/hide function available in the command centre.
Testing Instructions
Similar to the testing instructions in #71203 but for the command centre
Cmd/Ctrl + kto open the command center, and observe the"Hide"command."Show"them.Screenshots or screencast
Kapture.2025-10-08.at.18.31.51.mp4