[material-ui][Tab] Fix applying iconWrapper styles from theme and update its description#42549
[material-ui][Tab] Fix applying iconWrapper styles from theme and update its description#42549ZeeshanTamboli merged 12 commits intomui:nextfrom
iconWrapper styles from theme and update its description#42549Conversation
Netlify deploy previewhttps://deploy-preview-42549--material-ui.netlify.app/ Bundle size reportDetails of bundle changes (Toolpad) |
There was a problem hiding this comment.
This is incorrect. In the code, the iconWrapper class is applied to the icon itself when both icon (as a valid React element, not a string) and label props are present. You can also verify this in the second demo of this section in the docs.
This logic was added in #28982 to replace the extra span element wrapper with React.cloneElement and then apply the className to fix :first-child warnings.
I understand the name iconWrapper is confusing indicating a "wrapper", but we can't change the class name in v5 only in v6. What we can do is update the style class description to:
Styles applied to the `icon` HTML element if both `icon` and `label` are provided.
What do you think about changing the style class name from iconWrapper to icon for v6 in this PR? cc @DiegoAndai
|
Agree on changing description of I don't think we can access For now, i've just updated description in this PR, we can update |
… into fix-tab-styles
We can do this: --- a/packages/mui-material/src/Tab/Tab.js
+++ b/packages/mui-material/src/Tab/Tab.js
@@ -42,6 +42,9 @@ const TabRoot = styled(ButtonBase, {
styles[`textColor${capitalize(ownerState.textColor)}`],
ownerState.fullWidth && styles.fullWidth,
ownerState.wrapped && styles.wrapped,
+ {
+ [`& .${tabClasses.iconWrapper}`]: styles.iconWrapper,
+ },
];
},
})(({ theme }) => ({Make sure to add a test.
Agree with you. And first create a new issue so that it is tracked. |
iconWrapper styles from themeiconWrapper styles from theme and change it's description
iconWrapper styles from theme and change it's descriptioniconWrapper styles from theme and update its description
…pdate its description (#42549) Co-authored-by: ZeeshanTamboli <zeeshan.tamboli@gmail.com>
|
Sorry I missed this
I agree, but let's deprecate |
…pdate its description (mui#42549) Co-authored-by: ZeeshanTamboli <zeeshan.tamboli@gmail.com>
Bug
According to docs, styles applied passed to
iconWrappershould be applied to wrapper element of icon, in this case it isTabRootcomponent. But styles are not getting applied as we can see in belowbeforesandboxBefore: https://stackblitz.com/edit/react-kgd9jj?file=Demo.tsx (background color should be red according theme but that's not the case)
After: Replace code in this demo with below code to see effects of fix