Skip to content

Render classic meta boxes in iframes - #82194

Closed
ellatrix wants to merge 1 commit into
trunkfrom
try/meta-box-iframe
Closed

ellatrix wants to merge 1 commit into
trunkfrom
try/meta-box-iframe

Conversation

@ellatrix

@ellatrix ellatrix commented Aug 28, 2026 •

Copy link
Copy Markdown
Member

What?

Renders classic meta boxes in iframes that load the classic edit screen, instead of moving server rendered markup into the editor page. This is the rendering swap only. Refreshing the boxes on revision restore builds on top of it in a follow up.

Why?

Classic meta boxes are PHP rendered snapshots that the editor moves around its own DOM and cannot re-render. An iframe gives them a real classic document of their own: classic scripts run natively with no deferred initialization, their markup and styles cannot collide with the editor, and the document can be loaded again at any time, which gives features like revision restore and collaboration a way to bring the boxes up to date.

How?

  1. The loader page. The existing meta box loader URL renders the classic edit screen. A new parameter trims that page down to the meta boxes: admin chrome and the classic editor are hidden, meta boxes registered for backwards compatibility are removed (the editor renders their replacements), each iframe renders only its locations, the classic autosave is dequeued, and form submissions are prevented.
  2. Two iframes. One in the settings sidebar for the side location, which sizes itself to its content, and one in the bottom pane for normal and advanced.
  3. Media queries answer for the parent window. The iframes are narrower than the window, so small screen styles would wrongly apply. A bootstrap script rewrites width based @media conditions through the CSSOM to all or not all based on parent.matchMedia(), keeps them updated on window resizes, and wraps window.matchMedia the same way. Desktop minimum widths are overridden where the sidebar is narrower than they allow.
  4. Cross-origin isolation. The editor page may send Document-Isolation-Policy (for client side media processing), and an isolated document cannot script same origin frames that are not isolated the same way. The loader page sends the same header under the same conditions.
  5. Saving. Unchanged request, new source: a submit event is dispatched in each iframe so meta boxes that serialize their values in submit handlers run first (TinyMCE saves its editors from its own submit handler, and a dispatched event never actually submits the form), then the fields inside the meta boxes are collected with the browser's own form serialization, merged with the base form data, and posted to the meta box loader as before.
  6. The editor page renders no meta boxes. The markup and callbacks are skipped there, the list of available meta boxes is dispatched from the filter that skips them, and the meta box visibility preferences are applied inside the iframe documents.

Known gaps

  • Unsaved meta box edits are lost when an iframe unmounts: closing the settings sidebar or switching to the Block tab for the side location. A follow up should keep the iframes mounted in a persistent layer positioned over their slots.
  • Plugin meta box scripts and styles still enqueue on the editor page even though nothing uses them there.
  • Third party plugin CSS written for desktop widths may need more overrides in the narrow sidebar iframe.

Testing Instructions

  1. Activate the gutenberg-test-plugins/side-meta-box-demo test plugin.
  2. Open a post. The demo side boxes render in the settings sidebar, the others in the Meta Boxes pane.
  3. Fill values in several boxes, including the TinyMCE box, and save. Reload and confirm they persisted.
  4. Toggle meta boxes in Preferences and confirm they hide and show.
npm run test:e2e -- --project=chromium test/e2e/specs/editor/plugins/meta-boxes.spec.js

Testing Instructions for Keyboard

Tab from the editor into the meta box pane and sidebar boxes; fields, postbox toggles, and the move buttons are reachable and operable with the keyboard inside the iframes.

Screenshots or screencast

Editor with meta boxes in the sidebar and pane

Use of AI Tools

Written with the assistance of Claude Code, reviewed and tested by hand.

@github-actions github-actions Bot added [Package] Editor /packages/editor [Package] Edit Post /packages/edit-post [Package] E2E Tests /packages/e2e-tests labels Aug 28, 2026
@github-actions

github-actions Bot commented Aug 28, 2026 •

Copy link
Copy Markdown

Size Change: -1.25 kB (-0.02%)

Total Size: 7.91 MB

📦 View Changed
Filename Size Change
build/modules/block-library/tabs/view.min.js 864 B +94 B (+12.21%) ⚠️
build/modules/boot/index.min.js 58.2 kB +94 B (+0.16%)
build/modules/edit-site-init/index.min.js 1.8 kB +15 B (+0.84%)
build/modules/workflow/index.min.js 18.6 kB +36 B (+0.19%)
build/scripts/block-directory/index.min.js 43.9 kB -90 B (-0.2%)
build/scripts/block-editor/index.min.js 477 kB +143 B (+0.03%)
build/scripts/block-library/index.min.js 370 kB +976 B (+0.26%)
build/scripts/commands/index.min.js 19.9 kB +35 B (+0.18%)
build/scripts/components/index.min.js 266 kB -38 B (-0.01%)
build/scripts/edit-post/index.min.js 52.5 kB +103 B (+0.2%)
build/scripts/edit-site/index.min.js 381 kB +119 B (+0.03%)
build/scripts/edit-widgets/index.min.js 22.5 kB -63 B (-0.28%)
build/scripts/editor/index.min.js 580 kB +81 B (+0.01%)
build/scripts/format-library/index.min.js 39.5 kB +159 B (+0.4%)
build/scripts/media-utils/index.min.js 200 kB +175 B (+0.09%)
build/scripts/patterns/index.min.js 12.3 kB +8 B (+0.07%)
build/scripts/preferences/index.min.js 3.37 kB +35 B (+1.05%)
build/styles/block-directory/style-rtl.css 2.08 kB -23 B (-1.09%)
build/styles/block-directory/style-rtl.min.css 1.09 kB -19 B (-1.72%)
build/styles/block-directory/style.css 2.08 kB -23 B (-1.09%)
build/styles/block-directory/style.min.css 1.09 kB -19 B (-1.72%)
build/styles/block-editor/content-rtl.css 5.65 kB -39 B (-0.69%)
build/styles/block-editor/content-rtl.min.css 4.13 kB -33 B (-0.79%)
build/styles/block-editor/content.css 5.65 kB -37 B (-0.65%)
build/styles/block-editor/content.min.css 4.13 kB -32 B (-0.77%)
build/styles/block-editor/style-rtl.css 20 kB -79 B (-0.39%)
build/styles/block-editor/style-rtl.min.css 17.1 kB -55 B (-0.32%)
build/styles/block-editor/style.css 20.1 kB -83 B (-0.41%)
build/styles/block-editor/style.min.css 17.1 kB -57 B (-0.33%)
build/styles/block-library/accordion-panel/style-rtl.css 118 B +41 B (+53.25%) 🆘
build/styles/block-library/accordion-panel/style-rtl.min.css 110 B +40 B (+57.14%) 🆘
build/styles/block-library/accordion-panel/style.css 118 B +41 B (+53.25%) 🆘
build/styles/block-library/accordion-panel/style.min.css 110 B +40 B (+57.14%) 🆘
build/styles/block-library/comment-template/style-rtl.css 213 B -8 B (-3.62%)
build/styles/block-library/comment-template/style-rtl.min.css 191 B -9 B (-4.5%)
build/styles/block-library/comment-template/style.css 213 B -7 B (-3.18%)
build/styles/block-library/comment-template/style.min.css 191 B -8 B (-4.02%)
build/styles/block-library/cover/style-rtl.css 2.5 kB -6 B (-0.24%)
build/styles/block-library/cover/style-rtl.min.css 1.83 kB -3 B (-0.16%)
build/styles/block-library/cover/style.css 2.51 kB -7 B (-0.28%)
build/styles/block-library/cover/style.min.css 1.82 kB -3 B (-0.16%)
build/styles/block-library/editor-rtl.css 12.7 kB -9 B (-0.07%)
build/styles/block-library/editor-rtl.min.css 10.4 kB +4 B (+0.04%)
build/styles/block-library/editor.css 12.7 kB -10 B (-0.08%)
build/styles/block-library/editor.min.css 10.4 kB +6 B (+0.06%)
build/styles/block-library/form-input/style-rtl.css 472 B -8 B (-1.67%)
build/styles/block-library/form-input/style-rtl.min.css 370 B -8 B (-2.12%)
build/styles/block-library/form-input/style.css 472 B -8 B (-1.67%)
build/styles/block-library/form-input/style.min.css 370 B -8 B (-2.12%)
build/styles/block-library/gallery/editor-rtl.css 1.68 kB +36 B (+2.18%)
build/styles/block-library/gallery/editor-rtl.min.css 677 B +33 B (+5.12%) 🔍
build/styles/block-library/gallery/editor.css 1.68 kB +36 B (+2.18%)
build/styles/block-library/gallery/editor.min.css 680 B +33 B (+5.1%) 🔍
build/styles/block-library/gallery/style-rtl.css 3.02 kB +61 B (+2.06%)
build/styles/block-library/gallery/style-rtl.min.css 1.92 kB +50 B (+2.68%)
build/styles/block-library/gallery/style.css 3.02 kB +59 B (+1.99%)
build/styles/block-library/gallery/style.min.css 1.92 kB +49 B (+2.62%)
build/styles/block-library/icon/style-rtl.css 323 B +52 B (+19.19%) ⚠️
build/styles/block-library/icon/style-rtl.min.css 252 B +44 B (+21.15%) 🚨
build/styles/block-library/icon/style.css 323 B +52 B (+19.19%) ⚠️
build/styles/block-library/icon/style.min.css 252 B +44 B (+21.15%) 🚨
build/styles/block-library/image/editor-rtl.css 1.62 kB -7 B (-0.43%)
build/styles/block-library/image/editor-rtl.min.css 652 B -8 B (-1.21%)
build/styles/block-library/image/editor.css 1.62 kB -8 B (-0.49%)
build/styles/block-library/image/editor.min.css 652 B -7 B (-1.06%)
build/styles/block-library/media-text/style-rtl.css 873 B -9 B (-1.02%)
build/styles/block-library/media-text/style-rtl.min.css 552 B -4 B (-0.72%)
build/styles/block-library/media-text/style.css 901 B -8 B (-0.88%)
build/styles/block-library/media-text/style.min.css 550 B -5 B (-0.9%)
build/styles/block-library/playlist-track/style-rtl.css 523 B -5 B (-0.95%)
build/styles/block-library/playlist-track/style-rtl.min.css 489 B -5 B (-1.01%)
build/styles/block-library/playlist-track/style.css 523 B -6 B (-1.13%)
build/styles/block-library/playlist-track/style.min.css 488 B -5 B (-1.01%)
build/styles/block-library/playlist/style-rtl.css 2.29 kB -6 B (-0.26%)
build/styles/block-library/playlist/style-rtl.min.css 2.2 kB -4 B (-0.18%)
build/styles/block-library/playlist/style.css 2.29 kB -5 B (-0.22%)
build/styles/block-library/playlist/style.min.css 2.21 kB -4 B (-0.18%)
build/styles/block-library/query/editor-rtl.css 1.38 kB -20 B (-1.43%)
build/styles/block-library/query/editor-rtl.min.css 438 B -15 B (-3.31%)
build/styles/block-library/query/editor.css 1.38 kB -20 B (-1.43%)
build/styles/block-library/query/editor.min.css 438 B -15 B (-3.31%)
build/styles/block-library/read-more/style-rtl.css 146 B -5 B (-3.31%)
build/styles/block-library/read-more/style-rtl.min.css 131 B -7 B (-5.07%) ✅
build/styles/block-library/read-more/style.css 146 B -5 B (-3.31%)
build/styles/block-library/read-more/style.min.css 131 B -7 B (-5.07%) ✅
build/styles/block-library/reset-rtl.css 936 B -18 B (-1.89%)
build/styles/block-library/reset-rtl.min.css 467 B -13 B (-2.71%)
build/styles/block-library/reset.css 936 B -18 B (-1.89%)
build/styles/block-library/reset.min.css 467 B -13 B (-2.71%)
build/styles/block-library/search/style-rtl.css 1.1 kB -16 B (-1.43%)
build/styles/block-library/search/style-rtl.min.css 668 B -18 B (-2.62%)
build/styles/block-library/search/style.css 1.1 kB -17 B (-1.52%)
build/styles/block-library/search/style.min.css 668 B -19 B (-2.77%)
build/styles/block-library/site-logo/editor-rtl.css 1.12 kB -9 B (-0.8%)
build/styles/block-library/site-logo/editor-rtl.min.css 703 B -6 B (-0.85%)
build/styles/block-library/site-logo/editor.css 1.12 kB -10 B (-0.88%)
build/styles/block-library/site-logo/editor.min.css 698 B -8 B (-1.13%)
build/styles/block-library/site-title/editor-rtl.css 136 B +43 B (+46.24%) 🚨
build/styles/block-library/site-title/editor-rtl.min.css 122 B +37 B (+43.53%) 🚨
build/styles/block-library/site-title/editor.css 136 B +43 B (+46.24%) 🚨
build/styles/block-library/site-title/editor.min.css 122 B +37 B (+43.53%) 🚨
build/styles/block-library/style-rtl.css 22.5 kB +60 B (+0.27%)
build/styles/block-library/style-rtl.min.css 19 kB +52 B (+0.27%)
build/styles/block-library/style.css 22.7 kB +65 B (+0.29%)
build/styles/block-library/style.min.css 19 kB +58 B (+0.31%)
build/styles/block-library/tab-list/style-rtl.css 399 B -12 B (-2.92%)
build/styles/block-library/tab-list/style-rtl.min.css 358 B -11 B (-2.98%)
build/styles/block-library/tab-list/style.css 400 B -13 B (-3.15%)
build/styles/block-library/tab-list/style.min.css 358 B -11 B (-2.98%)
build/styles/block-library/template-part/editor-rtl.css 1.3 kB -22 B (-1.67%)
build/styles/block-library/template-part/editor-rtl.min.css 368 B -19 B (-4.91%) ✅
build/styles/block-library/template-part/editor.css 1.3 kB -22 B (-1.67%)
build/styles/block-library/template-part/editor.min.css 368 B -19 B (-4.91%) ✅
build/styles/block-library/video/style-rtl.css 1.12 kB -7 B (-0.62%)
build/styles/block-library/video/style-rtl.min.css 202 B -4 B (-1.94%)
build/styles/block-library/video/style.css 1.12 kB -7 B (-0.62%)
build/styles/block-library/video/style.min.css 202 B -4 B (-1.94%)
build/styles/commands/style-rtl.css 2.18 kB -9 B (-0.41%)
build/styles/commands/style-rtl.min.css 1.2 kB -8 B (-0.67%)
build/styles/commands/style.css 2.18 kB -8 B (-0.37%)
build/styles/commands/style.min.css 1.2 kB -8 B (-0.66%)
build/styles/components/style-rtl.css 16.2 kB -161 B (-0.98%)
build/styles/components/style-rtl.min.css 13.7 kB -111 B (-0.8%)
build/styles/components/style.css 16.3 kB -173 B (-1.05%)
build/styles/components/style.min.css 13.7 kB -111 B (-0.8%)
build/styles/edit-post/style-rtl.css 2.83 kB -504 B (-15.1%) 👏
build/styles/edit-post/style-rtl.min.css 1.71 kB -274 B (-13.8%) 👏
build/styles/edit-post/style.css 2.84 kB -505 B (-15.12%) 👏
build/styles/edit-post/style.min.css 1.71 kB -275 B (-13.84%) 👏
build/styles/edit-site/style-rtl.css 21.7 kB -75 B (-0.34%)
build/styles/edit-site/style-rtl.min.css 17.9 kB -50 B (-0.28%)
build/styles/edit-site/style.css 21.7 kB -76 B (-0.35%)
build/styles/edit-site/style.min.css 17.9 kB -49 B (-0.27%)
build/styles/edit-widgets/style-rtl.css 5.06 kB -7 B (-0.14%)
build/styles/edit-widgets/style-rtl.min.css 3.64 kB -5 B (-0.14%)
build/styles/edit-widgets/style.css 5.06 kB -7 B (-0.14%)
build/styles/edit-widgets/style.min.css 3.64 kB -5 B (-0.14%)
build/styles/editor/style-rtl.css 31.6 kB -211 B (-0.66%)
build/styles/editor/style-rtl.min.css 27 kB -146 B (-0.54%)
build/styles/editor/style.css 31.6 kB -203 B (-0.64%)
build/styles/editor/style.min.css 27 kB -144 B (-0.53%)
build/styles/media-utils/style-rtl.css 2.36 kB -4 B (-0.17%)
build/styles/media-utils/style-rtl.min.css 1.33 kB -3 B (-0.22%)
build/styles/media-utils/style.css 2.35 kB -4 B (-0.17%)
build/styles/media-utils/style.min.css 1.33 kB -3 B (-0.22%)

compressed-size-action

@github-actions

github-actions Bot commented Aug 28, 2026 •

Copy link
Copy Markdown

Flaky tests detected in 338f1a2.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/33212021549
📝 Reported tests:

should insert media, convert to blocks, and undo in one step in /test/e2e/specs/editor/blocks/classic.spec.js, passed after 1 failed attempt.
Error: expect(locator).toBeChecked() failed

Locator: getByRole('checkbox', { name: '17deae33-18b5-49e8-b723-98e4d7aa6f72' })
Expected: checked
Error: strict mode violation: getByRole('checkbox', { name: '17deae33-18b5-49e8-b723-98e4d7aa6f72' }) resolved to 2 elements:
    1) <li tabindex="0" data-id="16" role="checkbox" aria-checked="false" class="attachment save-ready" aria-label="17deae33-18b5-49e8-b723-98e4d7aa6f72">…</li> aka getByRole('checkbox', { name: '17deae33-18b5-49e8-b723-' }).first()
    2) <li tabindex="0" data-id="16" role="checkbox" aria-checked="true" class="attachment details selected save-ready" aria-label="17deae33-18b5-49e8-b723-98e4d7aa6f72">…</li> aka getByRole('checkbox', { name: '17deae33-18b5-49e8-b723-' }).nth(1)

Call log:
  - Expect "toBeChecked" with timeout 30000ms
  - waiting for getByRole('checkbox', { name: '17deae33-18b5-49e8-b723-98e4d7aa6f72' })

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/classic.spec.js:69:5

The classic meta boxes now render in two iframes loading the classic
edit screen through the meta box loader URL: one in the bottom pane for
the normal and advanced locations, one in the settings sidebar for the
side location. The loader page trims the screen down to the meta boxes,
sends the same Document-Isolation-Policy header as the editor, and
rewrites dimension media queries so styles respond to the editor
window instead of the iframe. Saving dispatches a submit event in each
iframe so submit handlers and TinyMCE write their values, then collects
the fields with the browser's form serialization. The editor page no
longer renders the meta boxes at all.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ellatrix
ellatrix force-pushed the try/meta-box-iframe branch from c4feac1 to 338f1a2 Compare August 28, 2026 21:19
@github-actions github-actions Bot added [Package] Element /packages/element [Package] Server Side Render /packages/server-side-render [Package] Autop /packages/autop [Tool] Jest console /packages/jest-console [Tool] WP Scripts /packages/scripts [Package] Core data /packages/core-data [Tool] Jest preset /packages/jest-preset-default [Package] Components /packages/components [Package] Block library /packages/block-library [Tool] ESLint plugin /packages/eslint-plugin [Package] Block editor /packages/block-editor [Tool] Dependency Extraction Webpack Plugin /packages/dependency-extraction-webpack-plugin [Package] Icons /packages/icons [Package] Edit Site /packages/edit-site [Tool] Readable JS Assets Webpack Plugin /packages/readable-js-assets-webpack-plugin [Package] DataViews /packages/dataviews [Package] Fields /packages/fields [Package] UI /packages/ui [Package] wp-build /packages/wp-build [Package] Sync /packages/sync [Package] Abilities /packages/abilities and removed [Package] Editor /packages/editor labels Aug 28, 2026
@github-actions github-actions Bot added [Package] Grid /packages/grid [Package] Widget primitives /packages/widget-primitives [Package] Widget Dashboard /packages/widget-dashboard [Package] Views /packages/views labels Aug 28, 2026
@ellatrix
ellatrix changed the base branch from restore-revisions-on-the-server to trunk August 28, 2026 21:21
@ellatrix ellatrix changed the title Render classic meta boxes in iframes and refresh them on restore Render classic meta boxes in iframes Aug 28, 2026
@ellatrix ellatrix closed this Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Abilities /packages/abilities [Package] Autop /packages/autop [Package] Block editor /packages/block-editor [Package] Block library /packages/block-library [Package] Components /packages/components [Package] Core data /packages/core-data [Package] DataViews /packages/dataviews [Package] E2E Tests /packages/e2e-tests [Package] Edit Post /packages/edit-post [Package] Edit Site /packages/edit-site [Package] Element /packages/element [Package] Fields /packages/fields [Package] Grid /packages/grid [Package] Icons /packages/icons [Package] Server Side Render /packages/server-side-render [Package] Sync /packages/sync [Package] UI /packages/ui [Package] Views /packages/views [Package] Widget Dashboard /packages/widget-dashboard [Package] Widget primitives /packages/widget-primitives [Package] wp-build /packages/wp-build [Tool] Dependency Extraction Webpack Plugin /packages/dependency-extraction-webpack-plugin [Tool] ESLint plugin /packages/eslint-plugin [Tool] Jest console /packages/jest-console [Tool] Jest preset /packages/jest-preset-default [Tool] Readable JS Assets Webpack Plugin /packages/readable-js-assets-webpack-plugin [Tool] WP Scripts /packages/scripts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant