Commit 2815f85
authored
fix(theme): remove stale dark root class in light mode (#1960)
## Summary
- fix theme-store bootstrap so the DOM theme name is authoritative on
first load
- remove stale root/body `dark` classes when the active theme is light
- add a regression test covering light theme startup with stale dark
classes present
## Root cause
The frontend bootstrap path could trust a pre-existing `.dark` class
before reconciling against the authoritative DOM theme name. If that
class lingered on `<html>` from an earlier client-side mutation, a light
theme could still boot into Tailwind dark mode.
## Validation
- `pnpm test __test__/store/theme.test.ts`
- `pnpm test __test__/components/ThemeSwitcher.test.ts`
## Reference
-
https://product.unraid.net/p/dark-class-added-to-html-root-element-even-in-light-mode
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Tests**
* Added test coverage for theme initialization to verify correct
handling of light theme CSS variables and removal of stale dark mode
classes.
* **Refactor**
* Improved theme store initialization logic to read theme settings from
DOM CSS variables, with fallback to legacy initialization when needed.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->1 parent 26d5f8b commit 2815f85
2 files changed
+23
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
286 | 286 | | |
287 | 287 | | |
288 | 288 | | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
289 | 301 | | |
290 | 302 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
51 | 54 | | |
52 | 55 | | |
53 | 56 | | |
| |||
98 | 101 | | |
99 | 102 | | |
100 | 103 | | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | 104 | | |
108 | 105 | | |
109 | 106 | | |
| |||
208 | 205 | | |
209 | 206 | | |
210 | 207 | | |
211 | | - | |
212 | | - | |
| 208 | + | |
213 | 209 | | |
214 | 210 | | |
215 | 211 | | |
216 | 212 | | |
217 | 213 | | |
218 | | - | |
219 | | - | |
220 | | - | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
| |||
0 commit comments