Skip to content
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

Components Overrides not working in MUI 5 #1880

Open
kkaplita opened this issue Mar 4, 2022 · 7 comments
Open

Components Overrides not working in MUI 5 #1880

kkaplita opened this issue Mar 4, 2022 · 7 comments

Comments

@kkaplita
Copy link

kkaplita commented Mar 4, 2022

Components Overrides not working i MUI 5
image

Expected Behavior

Overrides should work (but defined in theme)

Current Behavior

Overrides in MUI 5 not working.

Tech Version
Material-UI 5.3.0
MUI-datatables 4.1.2
React 17.0.2
browser any
@Simrut
Copy link

Simrut commented Mar 7, 2022

I have the same problem, downgraded MUI to v4 for now and used such an overrideconst getMuiTheme = () => createMuiTheme({ overrides: { MUIDataTable: { root: { backgroundColor: "#FF000", }, }, MUIDataTableBodyCell: { root: { width: "200px", }, }, }, });
This is deprecated however

@kkaplita
Copy link
Author

kkaplita commented Mar 7, 2022

I have the same problem, downgraded MUI to v4 for now and used such an overrideconst getMuiTheme = () => createMuiTheme({ overrides: { MUIDataTable: { root: { backgroundColor: "#FF000", }, }, MUIDataTableBodyCell: { root: { width: "200px", }, }, }, }); This is deprecated however

you should use this way... components: { MUIDataTable: styleOverrides { root: { backgroundColor: "#FF000", }, }, }, but... there is some issue and not working

@macadiz
Copy link

macadiz commented Apr 6, 2022

I'm having the same issue. I think it must be related to the CSS class generation. If you inspect the DOM elements you won't see any class plain as MUIDataTableBodyCell-root, in this picture you can see tss-1qtl85h-MUIDataTableBodyCell-root.

image

@GabrielPRomero
Copy link

Hey, if you using css or styled components. You can try this, example if it is a div:

Styled component:
const StyledDataTable = styled(MUIDataTable)({ '& div[class*="MUIDataTableFilterList-root"]': { maxHeight: none, // add your style }, });

css:
div[class*="MUIDataTableFilterList-root"]': {
maxHeight: none,
// add your style
},

@ashfaqnisar
Copy link
Contributor

ashfaqnisar commented Apr 12, 2022

Hey @kkaplita, this issue has been fixed in the newest release 4.2.2 with this #1882 pr. Please take a look whether this version fixed you're issue.

@FlaviusBejan
Copy link

In my case when the table is rendered, the CSS is injected above the one for all the components. This breaks everything.
I've hidden the data showed on the rows and in the table.
Screenshot_5
Screenshot_7

@FlaviusBejan
Copy link

I'm not sure if this is related to the problem.
I've changed from the latest @emotion/styled 11.8.1 to 11.6.0 and the problem was solved.
I don't know how and why, but all the other mui components worked fine with 11.8.1 and only when the table was rendered everything was broken.
I've realized this when trying to do a demo in CodeSandbox. which failed with (0 , $csb___emotion_utils.registerStyles) is not a function. Changing to 11.6.0 removed the problem.
https://codesandbox.io/s/silly-goldstine-4lgfwi?file=/package.json
The solution was found here: mui/material-ui#31149

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants