-
-
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
[material-ui][Tab] Fix applying iconWrapper
styles from theme and update its description
#42549
Conversation
Netlify deploy previewhttps://deploy-preview-42549--material-ui.netlify.app/ Bundle size reportDetails of bundle changes (Toolpad) |
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.
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
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.
Looks good.
…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
iconWrapper
should be applied to wrapper element of icon, in this case it isTabRoot
component. But styles are not getting applied as we can see in belowbefore
sandboxBefore: 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