-
Notifications
You must be signed in to change notification settings - Fork 672
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
sx prop does not correctly apply theme in nested ThemeProviders with ColorMode #1456
Comments
Hi rezaabedian 👋 |
Any ideas how we can fix it? |
Short of rewriting |
We could split CollorModeProvider into actual React context provider and consumer? |
@atanasster @rezaabedian does one of you guys want to work on this? |
Happy to try to help, but will probably need some assistance. @hasparus |
@rezaabedian Sweet! Thanks! Of course, I'm here to help. Here's ColorModeProvider: https://github.com/system-ui/theme-ui/blob/develop/packages/color-modes/src/index.tsx#L126-L153
contributing tips: As the full repo build takes a while (I'm working on it, but not so trivial) you build only the packages you're changing with
There's just one Jest project in the entire repo, and you run a subset of tests like this:
|
Hi @hasparus , I didn't get an opportunity to look at this yet. Is there any chance one of the existing maintainers of theme-ui will be able to tackle it? |
Describe the bug
When having an application that has a nested ThemeProviders with the same theme and color modes but different values, toggling the colorMode changes the colorMode and theme in both the top level and nested theme provider, but when utilizing that theme in the nested component with the sx prop, the wrong colour gets applied.
To Reproduce
Here is a simple codesandbox that reproduces the issue. https://codesandbox.io/s/exciting-banzai-hrjom?file=/src/index.js
Expected behavior
In the example provided, I would expect the inner components background value for light mode to be "darkcyan", and it is if you print out the theme object. But when its applied to the div using
sx={{ bg: "background" }}
it applies "red".The text was updated successfully, but these errors were encountered: