Skip to content

Fix: restore editor canvas padding in classic themes#76864

Open
Shekhar0109 wants to merge 1 commit intoWordPress:trunkfrom
Shekhar0109:fix/editor-iframe-padding
Open

Fix: restore editor canvas padding in classic themes#76864
Shekhar0109 wants to merge 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

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>

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.

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

Labels

Backport to WP 7.0 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta 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

Status: 🔎 Needs Review

Development

Successfully merging this pull request may close these issues.

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

2 participants