Skip to content

Custom Colors: Fix block editor CSS in Gutenberg 22.6.0+ iframe context#47603

Merged
arthur791004 merged 2 commits intotrunkfrom
fix/custom-colors-block-editor-iframe
Mar 17, 2026
Merged

Custom Colors: Fix block editor CSS in Gutenberg 22.6.0+ iframe context#47603
arthur791004 merged 2 commits intotrunkfrom
fix/custom-colors-block-editor-iframe

Conversation

@arthur791004
Copy link
Contributor

@arthur791004 arthur791004 commented Mar 16, 2026

Related to THEME-132

Proposed changes

  • Add a dedicated print_block_editor_css() method to Colors_Manager_Common that adapts Custom Colors CSS selectors for the block editor iframe context introduced in Gutenberg 22.6.0+.
  • Update the enqueue_block_editor_assets hook to use the new method instead of print_theme_css().
  • The new method extends #editor .editor-styles-wrapper selectors to also match :root :where(.editor-styles-wrapper) inside the iframe, while preserving the original selector for backwards compatibility with older Gutenberg versions.
  • Enqueue custom colors as an inline style via wp_add_inline_style() instead of printing a raw <style> tag, which is the correct approach for the enqueue_block_editor_assets hook.

Other information

  • Generate changelog entries for this PR (using AI).

Related product discussion/links

Does this pull request change what data or activity we track or use?

No.

Testing instructions

  1. Activate a theme that supports Custom Colors (e.g. Morden).
  2. Set custom colors via Appearance → Customize → Colors & Backgrounds, especially the one with dark background
  3. Open the block editor (post or page editor).
  4. Before this patch: Custom color CSS does not apply inside the editor iframe on Gutenberg 22.6.0+.
  5. After this patch: Custom color CSS correctly applies inside the editor iframe. The editor preview should reflect the custom color choices.
  6. Verify that the frontend (wp_head) still renders custom colors correctly (no regression).

Gutenberg 22.6.0+ renders the editor in an iframe for all themes, so the
`#editor .editor-styles-wrapper` selector no longer matches inside the
iframe. Add a dedicated `print_block_editor_css` method that extends the
selector to also target `:root :where(.editor-styles-wrapper)` while
keeping the original selector for backwards compatibility.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@arthur791004 arthur791004 added the [Status] Needs Review This PR is ready for review. label Mar 16, 2026
@arthur791004 arthur791004 self-assigned this Mar 16, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 16, 2026

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (WordPress.com Site Helper), and enable the fix/custom-colors-block-editor-iframe branch.

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions
Copy link
Contributor

github-actions bot commented Mar 16, 2026

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!


Wpcomsh plugin:

  • Next scheduled release: Atomic deploys happen twice daily on weekdays (p9o2xV-2EN-p2)

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@arthur791004
Copy link
Contributor Author

arthur791004 commented Mar 16, 2026

Sync changes from 207833-ghe-Automattic/wpcom

@jp-launch-control
Copy link

jp-launch-control bot commented Mar 16, 2026

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/plugins/wpcomsh/custom-colors/colors.php 0/842 (0.00%) 0.00% 11 💔

Full summary · PHP report

Coverage check overridden by Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR .

Pass array() instead of null for the $deps parameter.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@arthur791004 arthur791004 added the Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR label Mar 17, 2026
@arthur791004 arthur791004 merged commit 6abcf92 into trunk Mar 17, 2026
71 checks passed
@arthur791004 arthur791004 deleted the fix/custom-colors-block-editor-iframe branch March 17, 2026 02:05
@github-actions github-actions bot removed the [Status] Needs Review This PR is ready for review. label Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR [Plugin] Wpcomsh

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant