Block visibility badge: use canvas iframe for viewport detection#76889
Block visibility badge: use canvas iframe for viewport detection#76889
Conversation
The inspector badge was measuring viewport width against the outer browser window instead of the canvas iframe. Pass the iframe window to useBlockVisibility so the badge matches actual block rendering. Fixes #76730
|
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: +28 B (0%) Total Size: 7.73 MB
ℹ️ View Unchanged
|
|
Flaky tests detected in e798ec7. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/23704643728
|
Summary
Fixes #76730
The hidden block badge in the inspector sidebar was using the browser window width to detect the current viewport. But blocks in the canvas use the iframe window width. When the browser window is narrow, the badge could say "Block is hidden on Desktop" even though the canvas is rendering at a different size.
This passes the canvas iframe's window to
useBlockVisibilityviauseBlockElement, matching whatuse-block-propsandblock-list/block.jsalready do.Test plan
Cmd + +).Kapture.2026-03-29.at.17.08.51.mp4