Repository navigation
Conversation
| <ViewportVisibilityInfo clientId={ renderedBlockClientId } /> | ||
| { ! isEditingStyleState && ( | ||
| <ViewportVisibilityInfo clientId={ renderedBlockClientId } /> | ||
| ) } |
There was a problem hiding this comment.
There was a problem hiding this comment.
There is a small issue though, the toggle has its own early return rendering logic that causes it to be not shown:
if (
! clientId ||
! viewport ||
! viewportLabel ||
blockEditingMode !== 'default' ||
blockVisibility === false ||
! hasBlockSupport( blockName, 'visibility', true )
) {
return null;
}So in those cases the visibility info isn't shown but nor is the toggle. I'm looking at a fix for this.
There was a problem hiding this comment.
I'm thinking out loud here, should we show the badge still if the block is hidden everywhere?
Maybe it's different to "responsive" editing because it's not rendered 🤔 I'm just wondering if a block is hidden everywhere and you enter responsive editing mode, if it'd be helpful to be able to toggle it off and apply viewport-specific rules.
Maybe a follow up.
|
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: +463 B (+0.01%) Total Size: 7.67 MB 📦 View Changed
|
|
Flaky tests detected in c36c521. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/28935366625
|
t-hamano
left a comment
There was a problem hiding this comment.
When the following conditions match, neither the Block is hidden badge in the block inspector nor the Visibility panel is displayed, making it slightly unclear whether the block is hidden. Is this intended?
- Select the Tablet viewport
- Enable Resposive editing
- Check "Omit from published content"
| trunk | This PR |
|---|---|
![]() |
![]() |
| const nextBlockVisibility = cleanEmptyObject( { | ||
| viewport: { | ||
| ...blockVisibility?.viewport, | ||
| [ viewport ]: isHiddenOnViewport ? false : undefined, | ||
| }, | ||
| } ); |
There was a problem hiding this comment.
| const nextBlockVisibility = cleanEmptyObject( { | |
| viewport: { | |
| ...blockVisibility?.viewport, | |
| [ viewport ]: isHiddenOnViewport ? false : undefined, | |
| }, | |
| } ); | |
| const nextBlockVisibility = { | |
| viewport: { | |
| ...blockVisibility?.viewport, | |
| [ viewport ]: isHiddenOnViewport ? false : undefined, | |
| }, | |
| }; |
Nit: This cleanEmptyObject seems redundant.
|
Just gave this a quick test run and noticed there seems to be a discrepancy between when "block is hidden in..." notice displays and the toggle shows in resizing from desktop to tablet: toggle_visibility.mp4Overall I'm not sure the toggle will be super useful, because hiding for a particular viewport is likely to be a flow where you hide one block on mobile and hide another version of the same block on tablet/desktop, so it might make more sense to do it all from the default "edit all breakpoints" view at once. Happy to be convinced otherwise though! |
Thanks for the PR. 100% agree it'd be great to have a way to connect visibility with responsive editing. TBH I think the "desktop shows all three toggles" is consistent with "Desktop = overview/all breakpoints". I guess the cost is that we'd essentially rebuilt the modal inside the inspector. |
The cost is also a large amount of block inspector real estate dedicated to a feature that isn't likely to be used very often. I'd hesitate to do this just for consistency, unless it's something we can add under an "advanced" tab or something. |
|
Apologies for the belated review. This seems a nice and simple improvement. What is the main feedback you are looking for? One thought that comes to mind is to show this at the bottom of the inspector, rather than at the top. Mostly to avoid layout shifts. But it's not strongly felt. |
That could work! I think we should reserve the top part to display more frequently used tools, which block visibility is very unlikely to be. |
|
This is too late now for 7.1, so lets put this on the backburner. |


What?
Shows a control in the block inspector that allows a user to easily toggle block visibility when responsive editing.
Why?
Viewport visibility allows hiding blocks on specific viewports, but until now it wasn't really connected at all to the new 'Responsive editing' option, which feels like a missing feature to me. The user has to open the viewport visibility modal which still displays options for every viewport, not the one selected.
How?
Adds a simple toggle for block visibility in a ToolsPanel that's shown whenever Responsive editing is enabled, and the user has tablet or mobile viewport selected.
Whether to show anything when 'Desktop' is selected is an open question. I personally think it's ok not to bother with that in a first iteration. Alternatively, an idea I had is that on desktop the UI could show toggles for all breakpoints (since the desktop option is considered as 'Edit across all breakpoints').
Testing Instructions
Screenshots or screencast
Use of AI Tools
OpenCode / Codex