msyavuz opened a new pull request, #40763:
URL: https://github.com/apache/superset/pull/40763

   ### SUMMARY
   
   In embedded mode, a theme passed via the Embedded SDK (`setThemeConfig`) was 
ignored whenever the dashboard had its own theme configured — the dashboard 
theme always won.
   
   Two theme sources render as nested React providers: the SDK theme applies on 
the global `ThemeController` (root `SupersetThemeProvider`), while the 
dashboard theme applies in `CrudThemeProvider`, which sits **deeper** in the 
tree. React context = innermost provider wins, so the dashboard theme shadowed 
the SDK override regardless of arrival order. The SDK config reached the global 
theme fine — it just never reached the dashboard subtree.
   
   Fix: `ThemeController` tracks an SDK-override flag (set in `setThemeConfig`, 
exposed via `hasThemeConfigOverride()` and reactively through theme context). 
When the override is active, `CrudThemeProvider` steps aside and renders 
children directly, letting the global SDK theme flow through. `setThemeConfig` 
is only ever called from the embedded entry point, so the flag stays `false` in 
the regular app and dashboard themes behave exactly as before there.
   
   ```tsx
   // CrudThemeProvider
   if (!dashboardTheme || hasThemeConfigOverride) {
     return <>{children}</>; // SDK override wins; don't shadow it
   }
   ```
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   N/A — theming behavior change, no static visual to capture.
   
   ### TESTING INSTRUCTIONS
   
   1. Create a custom theme (e.g. `colorPrimary: #034464`) and apply it to a 
dashboard.
   2. Embed that dashboard via the SDK with a theme override (e.g. 
`colorPrimary: #ff0000`).
   3. Dashboard now renders with the SDK override (`#ff0000`); previously it 
showed the dashboard theme.
   4. Embed without an override → dashboard theme still applies.
   
   Automated: `CrudThemeProvider.test.tsx` (override active vs. inactive), 
`ThemeController.test.ts` (flag behavior), `ThemeProvider.test.tsx` (context). 
All theme suites pass.
   
   ### ADDITIONAL INFORMATION
   
   - [x] Has associated issue: internal bug report PPR-1245
   - [ ] Required feature flags: No
   - [x] Changes UI — theming precedence for embedded dashboards
   - [ ] Includes DB Migration: No — frontend-only
   - [ ] Introduces new feature or API: No — bug fix
   - [ ] Removes existing feature or API: No


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to