Skip to content

fix: ensure editor fonts and widths are loaded in iframed editor#2649

Merged
laurelfulford merged 5 commits intotrunkfrom
fix/editor-iframe-colors-fonts
Mar 19, 2026
Merged

fix: ensure editor fonts and widths are loaded in iframed editor#2649
laurelfulford merged 5 commits intotrunkfrom
fix/editor-iframe-colors-fonts

Conversation

@laurelfulford
Copy link
Copy Markdown
Contributor

@laurelfulford laurelfulford commented Mar 12, 2026

All Submissions:

Changes proposed in this Pull Request:

In WordPress 7.0, the Gutenberg editor will always load in an iframe. This breaks our theme's font customizations, and also makes it so the body classes we need to change the editor width aren't loaded.

This PR takes a swing at fixing that by:

  • Changing how the font, colour, and editor override CSS files are enqueued using a different hook
  • Uses a hacky work-around to get specific body classes added to the editor's iframe body

How to test the changes in this Pull Request:

  1. Switch your test site to the latest WP 7.0 beta/RC.
  2. Navigate to the Customizer and switch up your fonts: pick a couple fonts from Google fonts that are not installed on your computer, and set them up as your font. Set the fallback to something noticeable (like monospace).
  3. Change your colours to something noticeably different.
  4. Create a new post and try editing it; note that your fonts aren't applied.
  5. Try switching the post template to the One Column Wide template, save, and refresh. Note your blocks aren't any wider.
  6. Apply this PR and run npm run build.
  7. Refresh the editor and confirm the font is loaded, and your template widths are applied.
  8. Confirm that the colours still work - try a group block with a background and a paragraph block with a background.
  9. Toggle between the different templates (and save and refresh) and confirm blocks are wider when the One Column Wide template selected.
  10. Roll back to the current WordPress release.
  11. Repeat the testing steps (applying fonts, colours, and different template widths), and confirm there are no issues.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@laurelfulford laurelfulford requested a review from a team as a code owner March 12, 2026 18:58
@laurelfulford laurelfulford requested review from Copilot and removed request for a team March 12, 2026 18:59
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Newspack theme’s block editor styling integration to keep custom fonts/colors and template-based editor widths working when the Gutenberg editor canvas is rendered inside an iframe (WP 7.0 behavior).

Changes:

  • Switches editor style enqueues from enqueue_block_editor_assets to enqueue_block_assets (with an is_admin() guard) so styles load for the iframe canvas.
  • Implements an iframe workaround by prefixing custom editor body classes with admin-color-, and updates editor override selectors to match.
  • Adjusts editor base styling to set box-sizing: border-box on .wp-block.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
newspack-theme/functions.php Moves editor style enqueues to enqueue_block_assets, versions them with theme version, and adds admin-color-* body class workaround for iframe editor.
newspack-theme/sass/style-editor-overrides.scss Updates body-class-based selectors to the new admin-color-newspack-* class names for width/layout overrides.
newspack-theme/sass/style-editor-base.scss Adds box-sizing: border-box to .wp-block to improve editor layout consistency.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread newspack-theme/functions.php
Comment thread newspack-theme/functions.php
@laurelfulford laurelfulford added the [Status] Needs Review The issue or pull request needs to be reviewed label Mar 12, 2026
@laurelfulford laurelfulford requested a review from a team March 12, 2026 19:18
Copy link
Copy Markdown
Member

@adekbadek adekbadek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as described.

Comment thread newspack-theme/functions.php Outdated
Copy link
Copy Markdown
Member

@adekbadek adekbadek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(the previous review mentioned a change request (removed now) which upon closer inspection turned out to be not needed)

@github-actions github-actions bot added [Status] Approved The pull request has been reviewed and is ready to merge and removed [Status] Needs Review The issue or pull request needs to be reviewed labels Mar 18, 2026
@laurelfulford laurelfulford merged commit f49912e into trunk Mar 19, 2026
6 checks passed
@laurelfulford laurelfulford deleted the fix/editor-iframe-colors-fonts branch March 19, 2026 14:47
@github-actions
Copy link
Copy Markdown

Hey @laurelfulford, good job getting this PR merged! 🎉

Now, the needs-changelog label has been added to it.

Please check if this PR needs to be included in the "Upcoming Changes" and "Release Notes" doc. If it doesn't, simply remove the label.

If it does, please add an entry to our shared document, with screenshots and testing instructions if applicable, then remove the label.

Thank you! ❤️

matticbot pushed a commit that referenced this pull request Mar 19, 2026
# [2.20.0-alpha.1](v2.19.0...v2.20.0-alpha.1) (2026-03-19)

### Bug Fixes

* **block-theme:** migrate newspack-theme modal checkout fixes ([#2648](#2648)) ([e4f9d91](e4f9d91))
* default pullquote borders ([#2630](#2630)) ([5eb0b76](5eb0b76))
* ensure editor fonts and widths are loaded in iframed editor ([#2649](#2649)) ([f49912e](f49912e))
* tweak subtitle to work with iframe editor ([#2650](#2650)) ([86d4193](86d4193))

### Features

* add an avatar size control for author bios ([#2647](#2647)) ([ccfb6b4](ccfb6b4))
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 2.20.0-alpha.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

matticbot pushed a commit that referenced this pull request Mar 30, 2026
# [2.20.0](v2.19.0...v2.20.0) (2026-03-30)

### Bug Fixes

* **block-theme:** migrate newspack-theme modal checkout fixes ([#2648](#2648)) ([e4f9d91](e4f9d91))
* default pullquote borders ([#2630](#2630)) ([5eb0b76](5eb0b76))
* ensure editor fonts and widths are loaded in iframed editor ([#2649](#2649)) ([f49912e](f49912e))
* tweak subtitle to work with iframe editor ([#2650](#2650)) ([86d4193](86d4193))

### Features

* add an avatar size control for author bios ([#2647](#2647)) ([ccfb6b4](ccfb6b4))
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 2.20.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released on @alpha released [Status] Approved The pull request has been reviewed and is ready to merge wp 7.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants