sadpandajoe opened a new pull request, #38644:
URL: https://github.com/apache/superset/pull/38644
### SUMMARY
Embedded dashboards were inheriting the user's OS dark/light mode preference
instead of defaulting to light mode. When both default and dark themes are
available via bootstrap data, `ThemeController.determineInitialMode()` defaults
to `ThemeMode.SYSTEM`, which reads `prefers-color-scheme` from the user's OS.
The SDK's `setThemeMode()` fires after initial render via postMessage, so the
wrong theme is shown first.
**Fix**: Add `initialMode` option to `ThemeControllerOptions`. Embedded
contexts pass `ThemeMode.DEFAULT` so they start in light mode. Main app
behavior is unchanged (still defaults to SYSTEM when both themes exist). The
SDK can still override the mode after init.
**Files changed:**
- `packages/superset-core/src/theme/types.ts` — Added `initialMode?:
ThemeMode` to `ThemeControllerOptions`
- `src/theme/ThemeController.ts` — Store and use `initialMode` as fallback
in `determineInitialMode()`
- `src/embedded/EmbeddedContextProviders.tsx` — Pass `initialMode:
ThemeMode.DEFAULT`
- `src/theme/tests/ThemeController.test.ts` — 6 new tests (72/72 passing)
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
**Before**: Embedded dashboard renders in dark mode if user's OS is set to
dark mode, ignoring SDK theme setting.
**After**: Embedded dashboard renders in light mode by default. SDK
`setThemeMode()` can still switch to dark/system.
### TESTING INSTRUCTIONS
1. Set your OS to dark mode
2. Load an embedded dashboard (via the Superset Embedded SDK)
3. Verify the dashboard renders in **light mode** by default
4. Call `setThemeMode('dark')` via the SDK — verify it switches to dark mode
5. Call `setThemeMode('system')` via the SDK — verify it follows OS
preference
6. Verify non-embedded Superset still follows system theme preference
### ADDITIONAL INFORMATION
- [ ] Has associated issue:
- [ ] Required feature flags:
- [x] Changes UI
- [ ] Includes DB Migration (follow approval process in
[SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] Migration is atomic, supports rollback & is backwards-compatible
- [ ] Confirm DB migration upgrade and downgrade tested
- [ ] Runtime estimates and downtime expectations provided
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
--
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]