Skip to content

Fix: restore editor canvas padding in classic themes#76864

Merged
t-hamano merged 1 commit intoWordPress:trunkfrom
Shekhar0109:fix/editor-iframe-padding
Apr 13, 2026
Merged

Fix: restore editor canvas padding in classic themes#76864
t-hamano merged 1 commit intoWordPress:trunkfrom
Shekhar0109:fix/editor-iframe-padding

Conversation

@Shekhar0109
Copy link
Copy Markdown
Contributor

What?

Closes #76863

This PR restores the expected 8px padding around the editor canvas when using classic themes. In WordPress 7.0 / Gutenberg, the padding defined in html :where(.editor-styles-wrapper) can be overridden by body { padding: 0 } introduced by global styles. As a result, the editor content touches the canvas edges.

Why?

Classic themes expect the editor canvas to have a default 8px padding. When this padding is overridden, the text appears flush with the edges of the editor iframe, which negatively affects the editing experience and makes the editor visually inconsistent with previous versions.

How?

This change moves the padding declaration from html :where(.editor-styles-wrapper) to .editor-styles-wrapper. Applying the padding directly to .editor-styles-wrapper ensures it cannot be unintentionally overridden by global styles affecting the body. The existing full-width block margin compensation logic remains unchanged.

Testing Instructions

  1. Activate a classic theme (for example, Twenty Twenty).
  2. Open the WordPress post editor.
  3. Narrow the browser width or switch to tablet view.
  4. Insert a paragraph or heading block.

Expected result: The editor canvas should display 8px padding around the content instead of the text touching the edges.

Testing Instructions for Keyboard

  1. Open the editor using the keyboard.
  2. Insert blocks and navigate between them using Tab and arrow keys.
  3. Verify the editor layout and spacing remain correct and no visual regressions occur.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 27, 2026

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: Shekhar0109 <shekh0109@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: andrewserong <andrewserong@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions github-actions bot added the [Package] Edit Post /packages/edit-post label Mar 27, 2026
Copy link
Copy Markdown
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! It works well in all cases for my test. I tested this PR using Twenty Twenty.

Default

classic.css is enqueued, and a default 8px padding overrides zero padding derived from default theme.json

Image

Add theme.json to theme

Add the following theme.json to the theme:

{
	"version": 3,
	"styles": {
		"spacing": {
			"padding": { "top": "1em", "right": "1em", "bottom": "1em", "left": "1em" }
		}
	}
}

classic.css is NOT enqueued, and the padding defined in theme.json is applied correctly.

Image

Ultimately, this pull request simply increases the CSS specificity of the selector to which padding is applied from 0-0-1 to 0-1-0.

I believe this approach will have no negative consequences, but since we are in the RC phase, let me double-check it. cc @WordPress/gutenberg-core

@t-hamano t-hamano added Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json Backport to WP 7.0 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta labels Mar 27, 2026
@github-project-automation github-project-automation bot moved this to 🔎 Needs Review in WordPress 7.0 Editor Tasks Mar 27, 2026
@t-hamano t-hamano moved this from 🔎 Needs Review to 📥 Todo in WordPress 7.0 Editor Tasks Mar 27, 2026
@t-hamano t-hamano moved this from 📥 Todo to 🏗️ In Progress in WordPress 7.0 Editor Tasks Mar 27, 2026
@t-hamano t-hamano moved this from 🏗️ In Progress to 🔎 Needs Review in WordPress 7.0 Editor Tasks Mar 27, 2026
@t-hamano t-hamano added the [Type] Bug An existing feature does not function as intended label Mar 27, 2026
@Shekhar0109
Copy link
Copy Markdown
Contributor Author

@t-hamano Thanks for reviewing and testing the PR. I appreciate the feedback and confirmation that the fix works well. Please let me know if any further changes are needed.

@t-hamano
Copy link
Copy Markdown
Contributor

If this PR does not cause any regressions, I would like to merge it next week and backport it to 7.0. The missing default padding affects many classic themes.

Copy link
Copy Markdown
Contributor

@andrewserong andrewserong left a comment

Choose a reason for hiding this comment

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

I like this idea. I did a quick search of themes in the theme directory via https://veloria.dev/ (searching on .editor-styles-wrapper) and most themes appear to be overriding other rules than padding, e.g. background color, font size, etc, rather than padding directly.

If themes are overriding padding then the specificity here still seems reasonable as a theme's styles should load in the correct order.

Most importantly, though, since classic themes don't render the overall template that post content lives within, ensuring the minimal padding here is high enough specificity to be applied, seems a reasonable approach to me. Also, full-width blocks still go edge-to-edge as expected:

Image

So, LGTM 👍

I tested across a random assortment of a half-dozen classic themes with > 50k installs on the theme directory and didn't run into any issues.

@t-hamano
Copy link
Copy Markdown
Contributor

@andrewserong Thanks for the additional review!

@t-hamano t-hamano added the props-bot Manually triggers Props Bot to ensure the list of props is up to date. label Apr 13, 2026
@github-actions github-actions bot removed the props-bot Manually triggers Props Bot to ensure the list of props is up to date. label Apr 13, 2026
@t-hamano t-hamano merged commit 9950d18 into WordPress:trunk Apr 13, 2026
56 of 58 checks passed
@github-project-automation github-project-automation bot moved this from 🔎 Needs Review to ✅ Done in WordPress 7.0 Editor Tasks Apr 13, 2026
@github-actions github-actions bot added this to the Gutenberg 23.0 milestone Apr 13, 2026
@github-actions github-actions bot removed the Backport to WP 7.0 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Apr 13, 2026
gutenbergplugin pushed a commit that referenced this pull request Apr 13, 2026
Co-authored-by: Shekhar0109 <shekh0109@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: andrewserong <andrewserong@git.wordpress.org>
@github-actions github-actions bot added the Backported to WP Core Pull request that has been successfully merged into WP Core label Apr 13, 2026
@github-actions
Copy link
Copy Markdown

I just cherry-picked this PR to the wp/7.0 branch to get it included in the next release: 81b5dc5

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

Labels

Backported to WP Core Pull request that has been successfully merged into WP Core Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Package] Edit Post /packages/edit-post [Type] Bug An existing feature does not function as intended

Projects

Development

Successfully merging this pull request may close these issues.

Post Editor: iframe editor canvas padding is overridden by zero in the classic theme

3 participants