mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-21 08:16:36 +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) {
|
||||||
if (themeSettings.dark) {
|
if (themeSettings.dark) {
|
||||||
cacheKey = `${cacheKey}__dark`;
|
cacheKey = `${cacheKey}__dark`;
|
||||||
themeRules = darkStyles;
|
themeRules = { ...darkStyles };
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectedTheme === "default") {
|
if (selectedTheme === "default") {
|
||||||
|
@ -67,15 +67,16 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
|
|||||||
if (!this.hass) {
|
if (!this.hass) {
|
||||||
return;
|
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
|
let themeSettings: Partial<HomeAssistant["selectedThemeSettings"]> = this
|
||||||
.hass!.selectedThemeSettings;
|
.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 =
|
let darkMode =
|
||||||
themeSettings?.dark === undefined ? darkPreferred : themeSettings?.dark;
|
themeSettings?.dark === undefined ? darkPreferred : themeSettings?.dark;
|
||||||
|
|
||||||
@ -84,18 +85,8 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
|
|||||||
? this.hass.themes.themes[themeSettings.theme]
|
? this.hass.themes.themes[themeSettings.theme]
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
if (selectedTheme) {
|
if (selectedTheme && darkMode && !selectedTheme.modes) {
|
||||||
// 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;
|
darkMode = false;
|
||||||
} else if (
|
|
||||||
!darkMode &&
|
|
||||||
!selectedTheme.modes?.light &&
|
|
||||||
selectedTheme.modes?.dark
|
|
||||||
) {
|
|
||||||
darkMode = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
themeSettings = { ...this.hass.selectedThemeSettings, dark: darkMode };
|
themeSettings = { ...this.hass.selectedThemeSettings, dark: darkMode };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user