-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[system] Use a custom sheet to set prepend
for GlobalStyles
#43632
[system] Use a custom sheet to set prepend
for GlobalStyles
#43632
Conversation
Netlify deploy previewhttps://deploy-preview-43632--material-ui.netlify.app/ @mui/joy: parsed: +0.06% , gzip: +0.08% Bundle size reportDetails of bundle changes (Toolpad) |
f333985
to
778a774
Compare
Thanks for working on this @siriwatknp!
Does this mean that
I agree with you that we should fix it on our side, but let's also create an issue in Emotion's repo to see if this is a bug on their side that they can eventually fix. We shouldn't wait for it, but if they eventually fix it we can simplify our implementation. |
Yes and No, it works with |
The issue is already there emotion-js/emotion#2790 (I put a comment here) |
packages/mui-styled-engine/src/StyledEngineProvider/StyledEngineProvider.js
Show resolved
Hide resolved
…neProvider.js Co-authored-by: Diego Andai <[email protected]> Signed-off-by: Siriwat K <[email protected]>
…emotion-engine-provider
closes #43482
Root cause
Emotion does not pass
prepend
inGlobalStyles
, see https://github.com/emotion-js/emotion/blob/main/packages/react/src/global.js#L94-L99, so the global CSS always inject at the end of head for client-side apps.This PR create a custom sheet that will preserve the
prepend
flag.Before: The text is blue
index.css
cannot override even using<StyledEngineProvider injectFirst>
, see sandboxAfter: The text is now red due to
index.css
overrides, see sandbox