Block Visibility: Keep hide-everywhere working after a block opts out of visibility support#78780
Conversation
…disabled Blocks that previously supported visibility (HTML and Shortcode) silently reappear on the front end when content saved with `metadata.blockVisibility: false` is rendered after their support was disabled in #76138. Move the `block_has_support` check to run only for viewport-based visibility so the boolean `false` (hide everywhere) value continues to hide the block regardless of the block's current visibility support.
|
I'm not yet convinced if this approach is ideal. If we are to move forward with this PR, I would like to submit a core PR. |
|
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 Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @krysek76. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. 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 85df3c4. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/26814187492
|
|
Another option could be to make the block supports more granular. The shortcode and HTML block could use config like this and the users then get back the ability to toggle the blocks:
My understanding is that still works for those blocks because the 'everywhere' feature doesn't use css classnames, it completely skips rendering the block. I don't like 'everywhere' as the term, but hopefully you get the general idea. |
|
Thanks for the review!
After creating the core ticket and core PR, I would like to merge this PR. |
What?
Closes #78701
Honor
metadata.blockVisibility: falseon the front end even after a block opts out ofvisibilityblock support, so HTML and Shortcode blocks saved while their support was enabled stay hidden.Why?
Visibility support was disabled for the Shortcode block and the HTML block in #76138. This caused an unintended display of content on the front end.
How?
When metadata.visibility is false, block rendering is always prevented on the frontend.
As another issue, custom HTML blocks and shortcode blocks with
metadata.visibilityset tofalselack a UI in the editor to make them visible again. Users must delete these blocks once. It might be possible to adjust the visibility UI display logic in the editor, but this seems a bit complex, so this PR focuses solely on frontend fixes.Testing Instructions
Input the following code using the code editor:
The content should not be displayed on the front end.
Use of AI Tools
Drafted with Claude Code (Opus 4.7). All output reviewed and validated by the author.