Repository navigation
fix: load core block styles unscoped so responsive embeds size correctly - #786
Conversation
Passing block-library and block-editor content styles to the non-iframed block canvas scoped them under .editor-styles-wrapper, so selectors that rely on <body> classes such as wp-embed-responsive never matched and aspect-ratio embeds collapsed to zero height. WordPress never scopes these stylesheets, and loading them in the base layer also restores theme styles overriding them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
XCFramework BuildThis PR's XCFramework is available for testing. Add the following to your .package(url: "https://github.com/wordpress-mobile/GutenbergKit", branch: "pr-build/786")Built from 668d681 |
Aspect-ratio embeds previously collapsed to zero height without any test failing. The fixture now uses real 600x338 dimensions, as the previous 200x113 earned no aspect-ratio classes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Upstream content styles now load before GutenbergKit's stylesheet, so the leading body no longer guards against losing on source order. Pin the upstream link to the referenced lines. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nbradbury
left a comment
There was a problem hiding this comment.
@dcalhoun The changes look good to me and I'll approve. Claude reported a couple issues than may or may not need to be addressed. ![]()
| Severity | Location | Issue | Impact |
|---|---|---|---|
| Medium | visual-editor/index.jsx:78 |
Dropping ...canvasStyles moves block-library, content.css and components styles from last place in the cascade, inside BlockCanvas, to the first stylesheet in <head>. |
The non-iframed :where(.editor-styles-wrapper) scope adds no specificity, so these rules used to win every tie. Now theme editor styles, commonStyles, defaultThemeStyles and GutenbergKit SCSS such as .gutenberg-kit-visual-editor .wp-block-image > div:first-child win those ties, which can change how blocks and placeholders render (the new test only checks the YouTube embed height). |
| Medium | editor-styles.js:7 |
Loading block-library style.css and block-editor content.css globally reverses 097df6a's deliberate canvas scoping, when adding wp-embed-responsive to blockListClasses inside the wrapper might fix the embed on its own. |
Rules such as :where(figure){margin:0 0 1em}, .screen-reader-text and html :where(img[class*=wp-image-]) now reach editor chrome like the inserter, popovers, modals and toolbar, not just the canvas. |
|
@nbradbury thanks. I believe both are benign. For the first, the reorder is correct in that it aligns with WP Admin's ordering. I did manually test the Featured Image and Cover block placeholders when making this change, and those render as expected. For the second, this was an intentional reversal of the canvas scoping to align with WP Admin's usage of body classes. There is risk of style leakage to the editor chrome, but it is necessary and tolerated by WP Admin as well. |
What?
Fix collapsed YouTube embeds.
Why?
YouTube embeds rendered with a height of zero, and the video could not be seen.
How?
Hoist core block styles to the
bodyrather than scoping them to the visual editor element. Previously, the styles were not applied to the embed due to the incorrect nested selector.Testing Instructions
Accessibility Testing Instructions
N/A, no changes to navigation.
Screenshots or screencast
AI-generated details
Problem: Aspect-ratio embeds (e.g., YouTube) render at zero height. Since #247,
block-library/style.cssandblock-editor/content.cssare passed to the non-iframedBlockCanvas, which scopes them under:where(.editor-styles-wrapper). The responsive embed rules (.wp-embed-responsive .wp-has-aspect-ratio iframe) then requirewp-embed-responsiveinside the wrapper, but GutenbergKit sets it on<body>, so they never match. WordPress never scopes these stylesheets, whether the canvas is iframed or not.Change: Load those stylesheets (and RTL variants) unscoped in the
injectEditorStylesbase layer, ordered like WordPress'swp-edit-blocksdependencies. Drop the canvas copies, including the duplicatecomponents/style.cssandblock-library/editor.css. The canvas now only receives theme styles and GutenbergKit's default/common styles, so theme styles again come after the core block styles, as in WordPress.Related regressions: #332 (Cover popover broken by scoping) and #363 (Featured Image button lost a source-order tie to the duplicate canvas
components/style.css) both trace back to #247. With one copy of each stylesheet in the base layer,editor.cssfollowscomponents/style.css, so the Featured Image button stays 48px.Font-size side effect: Block library's legacy
:rootpresets (huge: 42px,normal: 16px) no longer override other preset values. Without theme styles, GutenbergKit's default theme styles now apply (huge: 96px,normal: 20px), matching behavior before #247. With theme styles, a theme's ownhuge/normalpresets now win, as in WordPress. This affects only content using the legacyhas-huge-font-size/has-normal-font-sizeclasses.Verified: iOS simulator: YouTube embed renders at 16:9 (342 × 192), Featured Image placeholder button is 48 × 48, and Cover was checked manually. A new E2E test asserts the embed preview keeps its 16:9 height; it fails with a height of
0without this fix.🤖 Generated with Claude Code