-
-
Couldn't load subscription status.
- Fork 32.7k
[system] Add shouldForwardProp to theme component configuration
#47103
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
base: master
Are you sure you want to change the base?
Conversation
…ess) Co-authored-by: michelengelen <32863416+michelengelen@users.noreply.github.com>
…eeded Co-authored-by: michelengelen <32863416+michelengelen@users.noreply.github.com>
Co-authored-by: michelengelen <32863416+michelengelen@users.noreply.github.com>
Netlify deploy previewhttps://deploy-preview-47103--material-ui.netlify.app/ Bundle size report
|
shouldForwardProp to theme component configuration
|
@copilot please remove the IMPLEMENTATION_NOTES.md file from the PR |
Co-authored-by: michelengelen <32863416+michelengelen@users.noreply.github.com>
|
|
||
| // Global registry to track theme shouldForwardProp configurations | ||
| // Maps componentName -> Set of registered shouldForwardProp functions | ||
| const themeShouldForwardPropRegistry = new Map(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like this approach. It could mess up with multiple ThemeProvider.
Add
shouldForwardPropto themeThis PR adds support for
shouldForwardPropin theme component configuration to prevent custom variant props from being forwarded to the DOM.Implementation Complete ✅
shouldForwardPropoption to theme component configuration typescreateStyled.jsto respect theme-levelshouldForwardPropThemeProviderto register theme shouldForwardProp configurationsStill TODO 🔧
What This Adds
Users can now specify
shouldForwardPropin theme configuration to prevent custom props from reaching the DOM:Architecture
Global Registry Pattern: A registry maps component names to their theme
shouldForwardPropfunctions. The styled component'sshouldForwardPropis wrapped to check both component-level and theme-level configurations.Registration: ThemeProvider registers configurations in
useMemobefore children render.Prop Filtering: The wrapped
shouldForwardPropchecks the registry at runtime for each prop.Files Changed
packages/mui-material/src/styles/components.ts- Added shouldForwardProp field to all componentspackages/mui-system/src/createStyled/createStyled.js- Registry and wrapper logicpackages/mui-system/src/ThemeProvider/ThemeProvider.js- Registration logicpackages/mui-system/src/styled/styled.test.js- Comprehensive testsKnown Issues
Tests show props are still being forwarded despite the implementation. Further debugging needed to identify if this is a timing issue, Emotion caching, or logic error.
Original prompt
Fixes #34831
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.