-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
Box clone not overriding child component styles #15993
Comments
@amakk We can't help without a reproduction. |
@kptlronyttcna thanks for the reproduction. When using the This works: import Typography from "@material-ui/core/Typography";
import Box from "@material-ui/core/Box"; This doesn't work: import Box from "@material-ui/core/Box";
import Typography from "@material-ui/core/Typography"; |
Hmm, It appears that this works:
but this does not:
In both cases |
Has anyone had a chance to look into this? In the mean time, what I have done is copied the
|
Moving to #15561 |
Adding to @amakk suggestion, we should do this: styleFunction.filterProps = innerStyleFunction.filterProps; so that Box doesn't inject unknown properties to the DOM. |
I'm using Box with the clone property (https://material-ui.com/components/box/#overriding-material-ui-components) and I'm seeing that the Box styles get overridden by the component's styles.
I've confirmed that Box is imported last in the file, but its styles are still not taking precedence. I tried to replicate it in a minimal repo, but it is working there, and I'm not able to narrow down to what is breaking the functionality because it's not consistent - sometimes it works, sometimes it doesn't. I'd like to provide information to track down this issue
I'm using Gatsby and the Gatsby plugin for Material UI, if that helps.
Expected Behavior 🤔
The box CSS should take precedence over the child component class.
Current Behavior 😯
The child component CSS is taking precedence.
Here are my imports:
![Screen Shot 2019-05-31 at 9 13 31 PM](https://user-images.githubusercontent.com/6800664/58742369-0d493c00-83ea-11e9-822a-9456eb5f3ace.png)
Here is my usage of box:
![Screen Shot 2019-05-31 at 9 13 56 PM](https://user-images.githubusercontent.com/6800664/58742370-16d2a400-83ea-11e9-850d-c4d23f9c4837.png)
Here is the CSS that's generated, as you can see the box class has lower precedence
![Screen Shot 2019-05-31 at 9 15 36 PM](https://user-images.githubusercontent.com/6800664/58742377-2f42be80-83ea-11e9-855d-32183652dad6.png)
Steps to Reproduce 🕹
I'm not able to create a repository that reproduces this issue. I started with the example gatsby starter and pasted a lot of my code into it, and got it to a point where it wasn't working. Then I started removing code to see how to minimize the example, and it started working again. When I undid the changes, it continued working, so I'm not able to reproduce this bug consistently.
If anyone has some ideas what it could be, or what I could try, I would appreciate it. At this point I'm really stuck, but would like to work with someone to resolve the issue.
https://codesandbox.io/s/hardcore-resonance-by6zt
Context 🔦
I'm trying to use box to override styles on another component. Would really like to have this functionality working.
Your Environment 🌎
The text was updated successfully, but these errors were encountered: