Commit a239495
committed
🤖 fix(storybook): remove theme sync race condition
Removed duplicate theme application logic that was causing conflicts
between the preview decorator and ThemeProvider.
Previously, both `syncStorybookTheme()` and `ThemeProvider`'s
`applyThemeToDocument()` were trying to control document.documentElement,
causing race conditions where some light mode stories would render as
dark (e.g., ErrorMessage Long message).
Changes:
- Removed `applyStorybookTheme()` and `syncStorybookTheme()` functions
- Simplified decorator to only pass forcedTheme to ThemeProvider
- ThemeProvider now disables persistence listener when forcedTheme is set
- Toggle is disabled when theme is forced (prevents conflicts)
This makes ThemeProvider the single source of truth for theme application,
eliminating timing issues and localStorage conflicts.
Net: -40 lines1 parent dd40c7e commit a239495
2 files changed
+6
-45
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
6 | 4 | | |
7 | 5 | | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | 6 | | |
48 | 7 | | |
49 | 8 | | |
| |||
62 | 21 | | |
63 | 22 | | |
64 | 23 | | |
65 | | - | |
66 | 24 | | |
67 | 25 | | |
68 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
68 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
69 | 72 | | |
70 | 73 | | |
71 | 74 | | |
| |||
0 commit comments