Skip to content

Site Editor: Use inverted ThemeProvider seed for portaled UI - #81296

Merged
t-hamano merged 6 commits into
wp/7.1from
edit-site-inverted-theme-seed
Aug 12, 2026
Merged

t-hamano merged 6 commits into
wp/7.1from
edit-site-inverted-theme-seed

Conversation

@mirka

@mirka mirka commented Aug 6, 2026

Copy link
Copy Markdown
Member

What?

Uses an inverted ThemeProvider seed in the site editor layout so portaled popovers and modals receive admin color scheme tokens.

Alternative to #81183 for the 7.1 release branch.

Why?

Portaled popovers and modals render outside their ancestor ThemeProvider wrapper in the DOM, so they do not receive the CSS custom properties on that wrapper. In the site editor, WPDS-styled UI inside popovers and modals can therefore miss the chosen admin color scheme's primary/accent colors.

#81183 fixes this at the Popover/Modal level by wrapping portaled content in ThemeProvider. That is the more general long-term fix, but for 7.1 we want a smaller change that avoids adding an extra wrapper to widely used components this close to release.

This follows the inverted seed pattern suggested by @t-hamano in #81183 (review), already used in the boot package: an outer isRoot provider seeds accent + content background for portaled UI, while an inner provider applies the full admin scheme to the editor chrome.

How?

  • Add an outer ThemeProvider with isRoot, seeding primary from the admin color scheme and a white content background (CONTENT_COLOR).
  • Nest the existing ThemeProvider color={ themeColors } inside it for the site editor chrome.

Testing Instructions

  1. Start wp-env and build the branch (npm start).
  2. Open the Site Editor (/wp-admin/site-editor.php).
  3. Switch admin color schemes under Users → Profile (e.g. Ocean, Midnight, Sunrise, Light).
  4. Reload the Site Editor and open a popover or modal, e.g. DataViews "View options" dropdown in Pages, dropdown menus or font modal in Styles.
  5. Confirm WPDS-styled UI inside the popover or modal reflects the chosen scheme's primary/accent colors.
  6. Confirm the site editor chrome still uses the admin scheme background color (not white).
  7. Smoke test the post editor for regressions.

@mirka mirka self-assigned this Aug 6, 2026
@mirka mirka added the [Type] Bug An existing feature does not function as intended label Aug 6, 2026
@mirka
mirka requested a review from a team August 6, 2026 18:15
@mirka
mirka marked this pull request as ready for review August 6, 2026 18:15
@mirka
mirka force-pushed the edit-site-inverted-theme-seed branch from c4ec8c9 to 930b90d Compare August 6, 2026 18:16
<ThemeProvider color={ themeColors }>
<Layout { ...props } />
<ThemeProvider
isRoot

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.

are we guaranteed that there won't be any other isRoot theme providers in the same browser page?

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.

Based on my research, Gutenberg itself should not cause duplicate theme providers with isRoot. The only possibility is if a third party injects its own theme provider with isRoot, but I believe this could happen in all editors, not just the Site Editor.

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.

Aside: We have console logging that emits in development environments in this kind of situation where duplicate isRoot exists, but maybe these could be throwing errors so this class of issue is more easily identified?

@github-actions

github-actions Bot commented Aug 7, 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: mirka <0mirka00@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: aduth <aduth@git.wordpress.org>

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

@aduth aduth left a comment

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.

LGTM 👍 Confirmed that this fixed an issue with focus rings not following color scheme in popovers in the Site Editor, and that the approach makes sense as essentially following what other themed page roots like @wordpress/boot's Root is already doing.

Before After
Screenshot 2026-08-11 at 9 56 07 AM Screenshot 2026-08-11 at 9 59 32 AM

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

Changes LGTM 🚀

Should we add a CHANGELOG entry for the @wordpress/edit-site package?

My preference (which can be a follow-up, if this PR needs to be merged soon) would be to add some resilience to the changes by:

  • potentially throwing in ThemeProvider (in dev mode) when multiple isRoot providers run in the same document;
  • potentially adding a side editor e2e test to verify that portalled components behave as expected with the changes from this PR (there are already popover-focused e2e tests, we could add another one);

@t-hamano

Copy link
Copy Markdown
Contributor

Thanks for the review, everyone. I would like to merge this after adding the changelog, in order to include it in tomorrow's 7.1 RC3 release.

@github-actions github-actions Bot added the [Package] Edit Site /packages/edit-site label Aug 11, 2026
@mirka

mirka commented Aug 11, 2026

Copy link
Copy Markdown
Member Author
  • potentially adding a side editor e2e test to verify that portalled components behave as expected with the changes from this PR (there are already popover-focused e2e tests, we could add another one)

By the way I consider this "inverted" approach in this PR basically as a hack, and not something we want to immortalize specifically in a test. The inverted approach only works for a specific, simple nesting structure, and will not work the moment there's a portaled dropdown coming from the dark sidebar for example, or more layers of nesting.

@ciampo

ciampo commented Aug 11, 2026

Copy link
Copy Markdown
Contributor
  • potentially adding a side editor e2e test to verify that portalled components behave as expected with the changes from this PR (there are already popover-focused e2e tests, we could add another one)

By the way I consider this "inverted" approach in this PR basically as a hack, and not something we want to immortalize specifically in a test. The inverted approach only works for a specific, simple nesting structure, and will not work the moment there's a portaled dropdown coming from the dark sidebar for example, or more layers of nesting.

Agreed! I thought we could add a test that will continue to work even after we refactor away from the hack

@github-actions

Copy link
Copy Markdown

Size Change: +14 B (0%)

Total Size: 7.75 MB

📦 View Changed
Filename Size Change
build/scripts/edit-site/index.min.js 304 kB +14 B (0%)

compressed-size-action

@t-hamano

Copy link
Copy Markdown
Contributor

Please note that the CI error is unrelated to this PR. #81444 (comment)

@ciampo

ciampo commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Should we bypass checks and merge, if all other checks pass?

@github-actions

github-actions Bot commented Aug 11, 2026 •

Copy link
Copy Markdown

Flaky tests detected in cc2a0fc.
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/31558780159
📝 Reported tests:

adds and activates a new tab when pressing Enter at the end of a tab label in /test/e2e/specs/editor/blocks/tabs.spec.js, passed after 1 failed attempt.
Error: expect(locator).toHaveCount(expected) failed

Locator:  locator('[name="editor-canvas"]').contentFrame().getByRole('document', { name: 'Block: Tab Panel' })
Expected: 3
Received: 2
Timeout:  5000ms

Call log:
  - Expect "toHaveCount" with timeout 5000ms
  - waiting for locator('[name="editor-canvas"]').contentFrame().getByRole('document', { name: 'Block: Tab Panel' })
    14 × locator resolved to 2 elements
       - unexpected value "2"

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/tabs.spec.js:173:27
should paginate, navigate pages, and diff across page boundaries in /test/e2e/specs/editor/various/revisions.spec.js, passed after 1 failed attempt.
Error: expect(received).toBe(expected) // Object.is equality

Expected: 1
Received: 100
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/revisions.spec.js:506:29
should paste block styles using keyboard in /test/e2e/specs/editor/various/list-view.spec.js, passed after 1 failed attempt.
Error: expect(received).toMatchObject(expected)

- Expected  - 6
+ Received  + 0

@@ -1,15 +1,9 @@
  Array [
    Object {
      "attributes": Object {
        "content": "First Block",
-       "style": Object {
-         "color": Object {
-           "background": "#00ff00",
-           "text": "#ff0000",
-         },
-       },
      },
      "name": "core/paragraph",
    },
    Object {
      "attributes": Object {

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/list-view.spec.js:653:41

@t-hamano

Copy link
Copy Markdown
Contributor

Should we bypass checks and merge, if all other checks pass?

I've updated this PR because #81444 was just backported to the wp/7.1 branch as well. This PR should now pass all CI checks.

Comment thread packages/edit-site/CHANGELOG.md Resolved
Comment thread packages/edit-site/CHANGELOG.md Resolved
@t-hamano
t-hamano merged commit b9743a0 into wp/7.1 Aug 12, 2026
51 of 54 checks passed
@t-hamano
t-hamano deleted the edit-site-inverted-theme-seed branch August 12, 2026 03:47
@github-project-automation github-project-automation Bot moved this from 🔎 Needs Review to ✅ Done in WordPress 7.1 Editor Tasks Aug 12, 2026
pento pushed a commit to WordPress/wordpress-develop that referenced this pull request Aug 12, 2026
This updates the pinned commit hash of the Gutenberg repository from `ea285b45692aed6c4f95353671393402f97f0aa7` to `b9743a015526ac8fd79298fd4e96cf002cee333b`.

A full list of changes included in this commit can be found on GitHub: 
WordPress/gutenberg@ea285b4...b9743a0

- Style states: fix state deselection when selecting the already selected block (WordPress/gutenberg#81277)
- Global styles: render element styles set only inside a breakpoint (WordPress/gutenberg#81265)
- Style states: Fix phantom pseudo element style output (WordPress/gutenberg#81291)
- Docs: remove breakpoint-only element style example from global styles guide (WordPress/gutenberg#81308)
- theme.json schema: responsive states belong to blocks (WordPress/gutenberg#81253)
- theme.json schema: allow responsive states on block style variations (WordPress/gutenberg#81309)
- Render viewport state element styles in the editor (WordPress/gutenberg#81307) (WordPress/gutenberg#81311)
- Site Editor: Decode HTML entities in Identity fields (WordPress/gutenberg#81269) (WordPress/gutenberg#81320)
- Editor: Keep the canvas height stable while resizing the canvas (WordPress/gutenberg#81374)
- Playlist: Normalize Waveform Player configuration handling (WordPress/gutenberg#81375)
- Playlist: Improve audio conversion and track selection (WordPress/gutenberg#80926) (WordPress/gutenberg#81385)
- fix: order site identity changes predictably (WordPress/gutenberg#81283)
- Cover: Avoid passing null as the featured image size (WordPress/gutenberg#81444)
- components/Menu: Restore Modal focus return when menu items close (WordPress/gutenberg#81446)
- Notes: Fix text wrapping for long usernames in collaboration sidebar (WordPress/gutenberg#81406)
- Site Editor: Use inverted ThemeProvider seed for portaled UI (WordPress/gutenberg#81296)

Props wildworks.
See #65529.

git-svn-id: https://develop.svn.wordpress.org/branches/7.1@63209 602fd350-edb4-49c9-b593-d223f7449a82
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Aug 12, 2026
This updates the pinned commit hash of the Gutenberg repository from `ea285b45692aed6c4f95353671393402f97f0aa7` to `b9743a015526ac8fd79298fd4e96cf002cee333b`.

A full list of changes included in this commit can be found on GitHub: 
WordPress/gutenberg@ea285b4...b9743a0

- Style states: fix state deselection when selecting the already selected block (WordPress/gutenberg#81277)
- Global styles: render element styles set only inside a breakpoint (WordPress/gutenberg#81265)
- Style states: Fix phantom pseudo element style output (WordPress/gutenberg#81291)
- Docs: remove breakpoint-only element style example from global styles guide (WordPress/gutenberg#81308)
- theme.json schema: responsive states belong to blocks (WordPress/gutenberg#81253)
- theme.json schema: allow responsive states on block style variations (WordPress/gutenberg#81309)
- Render viewport state element styles in the editor (WordPress/gutenberg#81307) (WordPress/gutenberg#81311)
- Site Editor: Decode HTML entities in Identity fields (WordPress/gutenberg#81269) (WordPress/gutenberg#81320)
- Editor: Keep the canvas height stable while resizing the canvas (WordPress/gutenberg#81374)
- Playlist: Normalize Waveform Player configuration handling (WordPress/gutenberg#81375)
- Playlist: Improve audio conversion and track selection (WordPress/gutenberg#80926) (WordPress/gutenberg#81385)
- fix: order site identity changes predictably (WordPress/gutenberg#81283)
- Cover: Avoid passing null as the featured image size (WordPress/gutenberg#81444)
- components/Menu: Restore Modal focus return when menu items close (WordPress/gutenberg#81446)
- Notes: Fix text wrapping for long usernames in collaboration sidebar (WordPress/gutenberg#81406)
- Site Editor: Use inverted ThemeProvider seed for portaled UI (WordPress/gutenberg#81296)

Props wildworks.
See #65529.
Built from https://develop.svn.wordpress.org/branches/7.1@63209


git-svn-id: http://core.svn.wordpress.org/branches/7.1@62402 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Edit Site /packages/edit-site [Type] Bug An existing feature does not function as intended

Projects

No open projects

Development

Successfully merging this pull request may close these issues.

4 participants