onurtashan opened a new pull request, #40760:
URL: https://github.com/apache/superset/pull/40760
## Summary
Reads the `?theme=` URL parameter on load and uses it as `initialMode` for
`ThemeController` in `EmbeddedContextProviders`, so embedded dashboards can
start in dark/system mode without a visible light-to-dark flash.
Closes #40759
## Changes
**`EmbeddedContextProviders.tsx`** — adds `getInitialThemeMode()`:
```typescript
function getInitialThemeMode(): ThemeMode {
const params = new URLSearchParams(window.location.search);
const theme = params.get('theme');
if (theme === 'dark') return ThemeMode.DARK;
if (theme === 'system') return ThemeMode.SYSTEM;
return ThemeMode.DEFAULT;
}
```
**`EmbeddedContextProviders.test.tsx`** — new test file covering all cases:
- `?theme=dark` → `ThemeMode.DARK`
- `?theme=system` → `ThemeMode.SYSTEM`
- `?theme=light` → `ThemeMode.DEFAULT` (fallback)
- no param → `ThemeMode.DEFAULT`
- unrecognised value → `ThemeMode.DEFAULT`
## No SDK changes required
The embed SDK already supports passing arbitrary URL params to the iframe
via `dashboardUiConfig.urlParams`. Host apps can use this today:
```typescript
embedDashboard({
...
dashboardUiConfig: {
urlParams: { theme: 'dark' },
},
});
```
## Backward compatibility
- No URL param → `ThemeMode.DEFAULT` (unchanged behaviour)
- `ThemeMode.SYSTEM` has an existing fallback guard in `isValidThemeMode` —
no additional handling needed
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
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]