gabotorresruiz opened a new pull request, #42815: URL: https://github.com/apache/superset/pull/42815
### SUMMARY `CrudThemeProvider` created a new `Theme` instance on every theme change (`Theme.fromConfig` inside a `useMemo` keyed on the theme's `json_data`). Each `Theme` binds its own `SupersetThemeProvider`, so a new instance means a new provider component identity, which forces React to unmount and remount the entire dashboard subtree whenever the applied theme changes. Consequences: * All charts in the dashboard reload on any theme change. * Transient dashboard state is discarded by the remount. In edit mode the "unsaved changes" flag is reset immediately after applying a theme, so the Save button never enables and a theme change cannot be saved through the UI. This backs the provider with a single, stable `Theme` instance that is updated in place via `Theme.setConfig`, keeping the `SupersetThemeProvider` identity stable so the subtree is not remounted. `Theme.setConfig` gains an optional `baseTheme` argument (the base-merge logic used by `fromConfig` is extracted into a shared `mergeConfig` helper) so the in-place update merges the dashboard theme over the light or dark base exactly as `fromConfig` does. The change is backward compatible: every existing `setConfig` caller passes a single argument and is unaffected, and `fromConfig` behavior is unchanged (verified against the `Theme` and `ThemeController` suites). Scope: this addresses changing the applied theme on a dashboard that already has one. Adding or removing a theme (no theme to theme) still toggles the provider presence and remounts once; that structural case is intentionally out of scope here. ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF Before: changing a dashboard's theme in edit mode reloads all charts and the Save button does not enable, so the theme change cannot be saved. After: changing the theme recolors the dashboard in place without reloading charts, and Save enables so the change persists. ### TESTING INSTRUCTIONS 1. Create a custom (non-system) theme under Settings > Themes. 2. Open a dashboard that already has a theme applied, enter edit mode, open Edit properties > Styling, change the Theme, and click Apply. 3. Confirm the dashboard recolors without the charts reloading and that the Save button becomes enabled. Save and reload to confirm the theme persisted. Unit tests: `CrudThemeProvider.test.tsx` adds a test asserting the `Theme` instance is reused and updated in place (not recreated) on a theme change, alongside the existing `Theme`, `ThemeController`, and `ThemeProvider` suites. ### ADDITIONAL INFORMATION - [x] Changes UI -- 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]
