Skip to content

fix: add wp-site-blocks class to MemoizedBlockList - #79629

Open
Swanand01 wants to merge 1 commit into
WordPress:trunkfrom
Swanand01:fix/block-gap-not-applied-to-template-thumbnails
Open

Swanand01 wants to merge 1 commit into
WordPress:trunkfrom
Swanand01:fix/block-gap-not-applied-to-template-thumbnails

Conversation

@Swanand01

Copy link
Copy Markdown
Contributor

What?

Closes #69492

Why?

blockGap set in theme.json under styles.spacing.blockGap has no visible effect in template thumbnails on the Site Editor's Templates list page. The thumbnails look flat/unspaced even when the full template editor renders the gap correctly.

Root cause: The CSS that drives blockGap targets .wp-site-blocks:

:root :where(.wp-site-blocks) > * { margin-block-start: ; margin-block-end: 0; }

The full template editor passes className="wp-site-blocks" to BlockList in VisualEditor. But the template thumbnail path — BlockPreview → AutoBlockPreview → ScaledBlockPreview — renders BlockList with no className, so the selector never matches inside the preview iframe and the gap is invisible.

Fix: Pass className="wp-site-blocks" to MemoizedBlockList in ScaledBlockPreview (packages/block-editor/src/components/block-preview/auto.js), bringing it in line with what VisualEditor already does.

How?

The fix is a single change in ScaledBlockPreview (packages/block-editor/src/components/block-preview/auto.js):

// Before
<MemoizedBlockList renderAppender={ false } />
// After
<MemoizedBlockList renderAppender={ false } className="wp-site-blocks" />

Testing Instructions

  1. Activate the Twenty Twenty-Five theme (it already has styles.spacing.blockGap: "1.2rem" in its theme.json).
  2. Open the Site Editor → Templates list.
  3. Observe the template thumbnails — blocks should have visible vertical spacing between them matching the theme's blockGap value.

Before this fix: thumbnails showed no gap between blocks regardless of what blockGap was set to in theme.json.
After this fix: thumbnails reflect the correct blockGap spacing, matching what you see when opening the template in the full editor.

Use of AI Tools

Claude Code

@Swanand01
Swanand01 requested a review from ellatrix as a code owner June 29, 2026 12:14
@github-actions

Copy link
Copy Markdown

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Required label: Any label starting with [Type].
  • Labels found: .

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

@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.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @realthemes.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

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

Unlinked contributors: realthemes.

Co-authored-by: Swanand01 <swanandm@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] Block editor /packages/block-editor label Jun 29, 2026

This branch has not been deployed

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

Labels

[Package] Block editor /packages/block-editor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

theme.json > styles > spacing > blockGap is not applied to template thumbnails in the Editor.

1 participant