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

[material-ui] v6 changed the injection order <GlobalStyles/> #44597

Closed
thenano opened this issue Nov 29, 2024 · 3 comments · Fixed by #44648
Closed

[material-ui] v6 changed the injection order <GlobalStyles/> #44597

thenano opened this issue Nov 29, 2024 · 3 comments · Fixed by #44648
Assignees
Labels
bug 🐛 Something doesn't work component: CssBaseline The React component component: GlobalStyles The React component. package: material-ui Specific to @mui/material

Comments

@thenano
Copy link

thenano commented Nov 29, 2024

Steps to reproduce

Steps:

  1. Checkout this codesandbox that displays the behaviour for v5: https://codesandbox.io/p/sandbox/mui-5-16-8-qylygf
  2. Checkout this codesandbox that displays the behaviour for v6: https://codesandbox.io/p/sandbox/mui-5-16-8-forked-h5ccxk?workspaceId=42d580f6-8e29-46e7-b91f-43fc4f1f64c5

As a note, although the v6 codesandbox uses the latest v6 version, I also tested with 6.0.0 which has the same behaviour.
As far as I can tell, the behaviour change comes from <StyledEngineProvider injectFirst>, which seems to have changed the injection order between CssBaseline and GlobalStyles

Current behavior

GlobalStyles defined are injected before CssBaseline

Expected behavior

GlobalStyles should be injected after CssBaseline so that they can take precedence over baseline, and we can avoid having to use !important, as was the behaviour in v5

Context

I need some specific pages in my application to be able to override the defined default body background

Your environment

as provided in the codesandboxes above

Search keywords: globalstyles body cssbaseline

@thenano thenano added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Nov 29, 2024
@zannager zannager added component: CssBaseline The React component component: GlobalStyles The React component. labels Nov 29, 2024
@aarongarciah aarongarciah added the package: material-ui Specific to @mui/material label Nov 29, 2024
@aarongarciah aarongarciah changed the title MUI v6 changed the injection order <GlobalStyles/> and has made it hard to overwrite styles applied to body [material-ui] v6 changed the injection order <GlobalStyles/> Nov 29, 2024
@DiegoAndai DiegoAndai moved this to Selected in Material UI Nov 29, 2024
@siriwatknp siriwatknp added bug 🐛 Something doesn't work and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Dec 3, 2024
@siriwatknp
Copy link
Member

This is a bug but I have to dig down to see if it's from our side or Emotion.

@thenano
Copy link
Author

thenano commented Dec 4, 2024

Thank you @siriwatknp! Let me know if I can help in any way.

@DiegoAndai DiegoAndai moved this from Selected to In progress in Material UI Dec 5, 2024
@github-project-automation github-project-automation bot moved this from In progress to Done in Material UI Dec 23, 2024
Copy link

This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

Note

@thenano How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: CssBaseline The React component component: GlobalStyles The React component. package: material-ui Specific to @mui/material
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants