Prevent darkMode overwrite by frontend_default_dark_theme #9519
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Breaking change
Proposed change
The active
this.hass.themeSettings.darkMode
selection got incorrectly overwritten in the following edge case:You have defined backend themes via
frontend_default_theme
andfrontend_default_dark_theme
and the OS is set to "dark preferred". The logic inside_applyTheme()
first determines the correct active dark mode (and applies the matching theme variant), but then a few lines later it got overwritten to dark becausedarkPreferred
andthis.hass.themes.default_dark_theme
were true whiledarkMode
can correctly be set to false, but "looses" in the boolean "||" operation.That meant that if you have selected the "light" radio box in the theme selection (while "Backend-selected" is the theme name), the overall theme was the light one (since it got applied a few lines after the initial correct darkMode determination), but inside
this.hass.themeSettings.darkMode
we had the wrong value.This problem was noticeable if in that configuration you go the HA general settings and you see that despite the light theme being used, the map of the location editor was in dark mode (since unless the caller provides a fixed
darkMode
value,<ha-map>
uses thethis.hass.themes.darkMode
).Type of change
Example configuration
Additional information
Checklist
If user exposed functionality or configuration variables are added/changed: