mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-24 21:37:21 +00:00
Fix resetting theme, only fallback to light when theme doesnt support… (#9253)
This commit is contained in:
parent
f55e911313
commit
de09e31815
@ -39,7 +39,7 @@ export const applyThemesOnElement = (
|
||||
if (themeSettings) {
|
||||
if (themeSettings.dark) {
|
||||
cacheKey = `${cacheKey}__dark`;
|
||||
themeRules = darkStyles;
|
||||
themeRules = { ...darkStyles };
|
||||
}
|
||||
|
||||
if (selectedTheme === "default") {
|
||||
|
@ -67,15 +67,16 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
|
||||
if (!this.hass) {
|
||||
return;
|
||||
}
|
||||
const themeName =
|
||||
this.hass.selectedThemeSettings?.theme ||
|
||||
(darkPreferred && this.hass.themes.default_dark_theme
|
||||
? this.hass.themes.default_dark_theme!
|
||||
: this.hass.themes.default_theme);
|
||||
|
||||
let themeSettings: Partial<HomeAssistant["selectedThemeSettings"]> = this
|
||||
.hass!.selectedThemeSettings;
|
||||
|
||||
const themeName =
|
||||
themeSettings?.theme ||
|
||||
(darkPreferred && this.hass.themes.default_dark_theme
|
||||
? this.hass.themes.default_dark_theme!
|
||||
: this.hass.themes.default_theme);
|
||||
|
||||
let darkMode =
|
||||
themeSettings?.dark === undefined ? darkPreferred : themeSettings?.dark;
|
||||
|
||||
@ -84,18 +85,8 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
|
||||
? this.hass.themes.themes[themeSettings.theme]
|
||||
: undefined;
|
||||
|
||||
if (selectedTheme) {
|
||||
// Override dark mode selection depending on what the theme actually provides.
|
||||
// Leave the selection as-is if the theme supports the requested mode.
|
||||
if (darkMode && !selectedTheme.modes?.dark) {
|
||||
darkMode = false;
|
||||
} else if (
|
||||
!darkMode &&
|
||||
!selectedTheme.modes?.light &&
|
||||
selectedTheme.modes?.dark
|
||||
) {
|
||||
darkMode = true;
|
||||
}
|
||||
if (selectedTheme && darkMode && !selectedTheme.modes) {
|
||||
darkMode = false;
|
||||
}
|
||||
|
||||
themeSettings = { ...this.hass.selectedThemeSettings, dark: darkMode };
|
||||
|
Loading…
x
Reference in New Issue
Block a user