Commit a6c6a97
committed
🤖 fix: apply theme synchronously in decorator before React renders
Root cause: useLayoutEffect in ThemeStorySync still created a race condition
where Chromatic could capture snapshots before the theme was applied.
Fix (same pattern as coder/coder):
- Apply theme to document.documentElement synchronously in decorator
- Pass forcedTheme prop to ThemeProvider so it doesn't read localStorage
- Decorator runs BEFORE React tree is created, ensuring theme is correct
- ThemeProvider respects forcedTheme and skips persistence/listener
This eliminates all timing issues - theme is on document before any
component renders or useLayoutEffect runs.1 parent 36f480d commit a6c6a97
File tree
2 files changed
+34
-32
lines changed- .storybook
- src/browser/contexts
2 files changed
+34
-32
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
| 3 | + | |
8 | 4 | | |
9 | 5 | | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | 6 | | |
23 | 7 | | |
24 | 8 | | |
| |||
37 | 21 | | |
38 | 22 | | |
39 | 23 | | |
40 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
41 | 34 | | |
42 | | - | |
43 | | - | |
| 35 | + | |
44 | 36 | | |
45 | 37 | | |
46 | 38 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
58 | 65 | | |
59 | 66 | | |
60 | | - | |
61 | | - | |
| 67 | + | |
| 68 | + | |
62 | 69 | | |
63 | 70 | | |
64 | | - | |
65 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
66 | 76 | | |
67 | 77 | | |
68 | 78 | | |
69 | | - | |
70 | | - | |
| 79 | + | |
| 80 | + | |
71 | 81 | | |
72 | 82 | | |
73 | | - | |
| 83 | + | |
74 | 84 | | |
75 | 85 | | |
76 | 86 | | |
| |||
0 commit comments