[system] Use a custom sheet to set prepend for GlobalStyles#43632
[system] Use a custom sheet to set prepend for GlobalStyles#43632siriwatknp merged 4 commits intomui:masterfrom
prepend for GlobalStyles#43632Conversation
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 <diego@mui.com> Signed-off-by: Siriwat K <siriwatkunaporn@gmail.com>
…emotion-engine-provider
closes #43482
Root cause
Emotion does not pass
prependinGlobalStyles, 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
prependflag.Before: The text is blue
index.csscannot override even using<StyledEngineProvider injectFirst>, see sandboxAfter: The text is now red due to
index.cssoverrides, see sandbox