Skip to content

[system] Skip styled component from being transformed #46129

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

Merged
merged 4 commits into from
May 21, 2025

Conversation

siriwatknp
Copy link
Member

@siriwatknp siriwatknp commented May 12, 2025

closes #46102

The root cause is explained here.

Added a regression test to ensure that the component selector works (see https://app.argos-ci.com/mui/material-ui/builds/38372/159820872).

@siriwatknp siriwatknp added package: system Specific to @mui/system v6.x needs cherry-pick The PR should be cherry-picked to master after merge labels May 12, 2025
@siriwatknp siriwatknp requested a review from DiegoAndai May 12, 2025 05:01
@mui-bot
Copy link

mui-bot commented May 12, 2025

Netlify deploy preview

https://deploy-preview-46129--material-ui.netlify.app/

Bundle size report

Details of bundle changes (Toolpad)
Details of bundle changes

Generated by 🚫 dangerJS against 5022a72

@siriwatknp siriwatknp requested a review from brijeshb42 May 12, 2025 06:49
Copy link
Member

@DiegoAndai DiegoAndai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @siriwatknp!

  • Do you know when was this bug introduced?
  • Have we checked if this change doesn't introduce other regressions? I'm worried that there are some objects we do want to serialize and might be skipped unintentionally after this change.

@siriwatknp siriwatknp requested a review from romgrk May 20, 2025 01:41
@siriwatknp
Copy link
Member Author

siriwatknp commented May 20, 2025

Do you know when was this bug introduced?

Since #43412 due to the preserialization. The full explanation is here.

Have we checked if this change doesn't introduce other regressions? I'm worried that there are some objects we do want to serialize and might be skipped unintentionally after this change.

All the tests are passed, so I don't think it will introduce other regression. I added a test for component selector, so that it prevents the regression in the future.

Please review the code again, I refactored to return the style earlier when it's a styled component from Emotion.

@DiegoAndai
Copy link
Member

Thanks for the refactor and explanation.

One question, as I'm not very familiar with Emotion internals: What is __emotion_real?

@siriwatknp
Copy link
Member Author

Thanks for the refactor and explanation.

One question, as I'm not very familiar with Emotion internals: What is __emotion_real?

Emotion attaches __emotion_real to the styled component so that I knows how to deal with when that component is styled again.

const Child = styled('div')``;
// Child.__emotion_real = Child

const Parent = styled(Child)``; << there is a logic within `styled` to use proper `shouldForwardProps` based on the tag.

@siriwatknp siriwatknp merged commit 4cfd2f7 into mui:master May 21, 2025
20 checks passed
Copy link

Cherry-pick PRs will be created targeting branches: v6.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs cherry-pick The PR should be cherry-picked to master after merge package: system Specific to @mui/system v6.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Component selectors no longer working with styled from @mui/material after upgrading to v6
4 participants