Skip to content

wp-build: Fix black flash on wp-admin pages before hydration#78493

Merged
t-hamano merged 6 commits into
WordPress:trunkfrom
itzmekhokan:fix/trac-65247
May 29, 2026
Merged

wp-build: Fix black flash on wp-admin pages before hydration#78493
t-hamano merged 6 commits into
WordPress:trunkfrom
itzmekhokan:fix/trac-65247

Conversation

@itzmekhokan

@itzmekhokan itzmekhokan commented May 21, 2026

Copy link
Copy Markdown
Contributor

What?

Fixes a brief black flash when navigating to wp-admin integrated boot pages (such as the Connectors screen) before React hydrates.

Why?

The page-wp-admin.php.template critical CSS set #wpwrap background to var(--wpds-color-fg-content-neutral, #1e1e1e). That is a foreground design token used as a background, so before @wordpress/boot hydrates and applies .boot-layout styles, the content area briefly renders as near-black.

This matches the boot layout background used after hydration:

.boot-layout {
	background: var(--wpds-color-bg-surface-neutral-weak, #f0f0f0);
}

How?

Updates #wpwrap critical CSS in packages/wp-build/templates/page-wp-admin.php.template to use var(--wpds-color-bg-surface-neutral-weak, #f0f0f0).

Generated page-wp-admin.php files in WordPress Core are built from this template, so the fix must land here rather than by editing generated files directly in wordpress-develop (see Core Trac #65247 and @westonruter's feedback on wordpress-develop PR #11892).

Testing Instructions

  1. Build/sync Gutenberg into WordPress Core (or use the Gutenberg plugin with a wp-build output that includes this template change).
  2. Navigate to Settings → Connectors in wp-admin.
  3. Confirm there is no black flash before the interface renders.
  4. Confirm the initial background matches the boot layout gray (#f0f0f0) before and after hydration.

Related

Use the boot layout background token for #wpwrap critical CSS instead of a
foreground color fallback that rendered as near-black before React mounted.

Fixes WordPress Core Trac WordPress#65247.
@github-actions

github-actions Bot commented May 21, 2026

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: itzmekhokan <khokansardar@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: westonruter <westonruter@git.wordpress.org>

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


/* Background colors */
#wpwrap {
background: var(--wpds-color-fg-content-neutral, #1e1e1e);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Note: The old value was originally introduced in c69eedf as part of #73977.

@westonruter

Copy link
Copy Markdown
Member

There is no black background color flashing after this change, so that's good.

Before:

Screen.Recording.2026-05-21.at.23.14.11.mov

After:

Screen.Recording.2026-05-21.at.23.13.32.mov

@westonruter westonruter added [Type] Bug An existing feature does not function as intended Backport to WP Minor Release Pull request that needs to be backported to a WordPress minor release labels May 22, 2026
Use the boot layout background token for #wpwrap critical CSS instead of a
foreground color fallback that rendered as near-black before React mounted.

Fixes WordPress Core Trac WordPress#65247.
@westonruter westonruter requested a review from t-hamano May 22, 2026 20:07
@github-project-automation github-project-automation Bot moved this to 🔎 Needs Review in WordPress 7.0 Editor Tasks May 23, 2026
@t-hamano t-hamano moved this from 🔎 Needs Review to 🐛 Punted to 7.0.1 in WordPress 7.0 Editor Tasks May 24, 2026
@t-hamano t-hamano moved this from 🐛 Punted to 7.0.1 to 🔎 Needs Review in WordPress 7.0 Editor Tasks May 24, 2026
@t-hamano

Copy link
Copy Markdown
Contributor

This matches the boot layout background used after hydration:

.boot-layout {
	background: var(--wpds-color-bg-surface-neutral-weak, #f0f0f0);
}

Is this true? Isn't the actual background of the rendered page --wpds-color-bg-surface-neutral?

Screenshot 0008-05-25 at 9 36 49

Also, as another approach, I'm curious what happens if we remove the background color itself from #wprap, since the body element already has a white background applied.

Drop the incorrect foreground token background on #wpwrap and rely on the
existing body background for pre-hydration paint. Keep overflow-y for the
high-zoom admin menu scroll fix from WordPress#73977.

Fixes WordPress Core Trac WordPress#65247.
@itzmekhokan

Copy link
Copy Markdown
Contributor Author

This matches the boot layout background used after hydration:

.boot-layout {
	background: var(--wpds-color-bg-surface-neutral-weak, #f0f0f0);
}

Is this true? Isn't the actual background of the rendered page --wpds-color-bg-surface-neutral?

Screenshot 0008-05-25 at 9 36 49 Also, as another approach, I'm curious what happens if we remove the background color itself from `#wprap`, since [the body element already has a white background applied](https://github.com/WordPress/gutenberg/blob/67c44e05fc2be4800cca4459b62474b2241a78ce/packages/wp-build/templates/page-wp-admin.php.template#L266-L268).

@t-hamano Thanks for the thoughtful review — both points are valid.

You're right that the visible Connectors content area uses --wpds-color-bg-surface-neutral on .boot-layout__canvas / __stage, not --wpds-color-bg-surface-neutral-weak on the outer .boot-layout shell. My earlier description was imprecise.

I also agree that removing the #wpwrap background is the cleaner fix. Looking at #73977, the #wpwrap rule was moved into critical CSS mainly for overflow-y: auto (the high-zoom admin menu scroll fix). The background: var(--wpds-color-fg-content-neutral, #1e1e1e) was a foreground token mistakenly applied as a background, which caused the black flash.

I've updated the PR to:

Remove the #wpwrap background entirely
Keep overflow-y: auto for the #73977 scroll behavior
Rely on the existing body { background: #fff; } for pre-hydration paint, which better matches the canvas surface

Could you take another look when you have a moment?

@t-hamano t-hamano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! Finally, could you just resolve the code conflicts?

Comment thread packages/wp-build/templates/page-wp-admin.php.template Outdated
@t-hamano t-hamano merged commit 6343b59 into WordPress:trunk May 29, 2026
38 checks passed
@github-project-automation github-project-automation Bot moved this from 🔎 Needs Review to ✅ Done in WordPress 7.0 Editor Tasks May 29, 2026
@github-actions github-actions Bot added this to the Gutenberg 23.4 milestone May 29, 2026
@simison

simison commented May 29, 2026

Copy link
Copy Markdown
Member

FYI, adding missing changelog entry for this change in #78807

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

Labels

Backport to WP Minor Release Pull request that needs to be backported to a WordPress minor release [Type] Bug An existing feature does not function as intended

Projects

Development

Successfully merging this pull request may close these issues.

4 participants