Skip to content

Commit c2dadb0

Browse files
committed
ThemeProvider: keep data-wpds-root-provider marker for CSS forwarding
Restores `data-wpds-root-provider="true"` on the wrapper when `isRoot`, so prebuilt CSS can forward preset-based settings (e.g. `cornerRadius` in #79153) to `:root` via `:root:has([data-wpds-root-provider="true"]…)`. Dynamic color/cursor values keep using the JS sync in `useLayoutEffect` (they can't be expressed in a static stylesheet). Comment updated to explain the deliberate split.
1 parent 2c668ee commit c2dadb0

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

packages/theme/src/theme-provider.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,16 @@ export const ThemeProvider = ( {
2626
[ resolvedSettings ]
2727
);
2828

29-
// Mirror the wrapper's custom properties onto `document.documentElement`
30-
// so they reach portals and anything else rendered outside the wrapper
31-
// (e.g. the `html`/`body` background). Unlike the wrapper, `html` is a
32-
// shared element, so we set/remove individual properties (preserving any
33-
// prior value) instead of declaratively assigning a full style object.
29+
// Mirror the wrapper's dynamic custom properties (color/cursor) onto
30+
// `document.documentElement` so they reach portals and anything else
31+
// rendered outside the wrapper (e.g. the `html`/`body` background, or
32+
// PHP-rendered admin UI alongside the React app). Preset-based settings
33+
// (e.g. `cornerRadius`) are forwarded declaratively by the prebuilt CSS
34+
// via `:root:has([data-wpds-root-provider="true"]…)`; only the per-seed
35+
// values that can't be expressed in a static stylesheet are synced here.
36+
// Unlike the wrapper, `html` is a shared element, so we set/remove
37+
// individual properties (preserving any prior value) instead of
38+
// declaratively assigning a full style object.
3439
useLayoutEffect( () => {
3540
if ( ! isRoot || typeof document === 'undefined' ) {
3641
return;
@@ -68,6 +73,7 @@ export const ThemeProvider = ( {
6873

6974
return (
7075
<div
76+
data-wpds-root-provider={ isRoot ? 'true' : undefined }
7177
data-wpds-corner-radius={ cornerRadiusPreset }
7278
className={ styles.root }
7379
style={ themeProviderStyles }

0 commit comments

Comments
 (0)