-
Notifications
You must be signed in to change notification settings - Fork 615
ThemeProvider: Fix theme sync with system settings #2048
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
510da40
135808b
4e65198
8c75b12
f59381d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@primer/react": patch | ||
--- | ||
|
||
ThemeProvider: Bug fix, in `colorMode=auto`, the theme now syncs with system changes. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,10 +101,6 @@ export const ThemeProvider: React.FC<ThemeProviderProps> = ({children, ...props} | |
setColorMode(props.colorMode ?? fallbackColorMode ?? defaultColorMode) | ||
}, [props.colorMode, fallbackColorMode]) | ||
|
||
React.useEffect(() => { | ||
setColorMode(resolvedColorMode) | ||
}, [resolvedColorMode]) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I split this effect in #1936, now this effect was just syncing state to colorMode 🤔 which is a bug There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think I understand this bug. Everything seems to be working as expected 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The bug was that it set const resolvedColorMode = resolveColorMode(colorMode, systemColorMode) so when the Then this effect came around and set |
||
React.useEffect(() => { | ||
setDayScheme(props.dayScheme ?? fallbackDayScheme ?? defaultDayScheme) | ||
}, [props.dayScheme, fallbackDayScheme]) | ||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to introduce a config to disable the theme decorator so that I can actually test ThemeProvider in an isolated story 😅