-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
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
[Link] Fix style overrides 5.6.0 regression #32182
Conversation
9ccd701
to
1363727
Compare
@@ -160,6 +160,7 @@ const Link = React.forwardRef(function Link(inProps, ref) { | |||
|
|||
return ( | |||
<LinkRoot | |||
color={color} |
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.
bring back this line to send color to Typography for <Link />
basic use case.
@@ -10,14 +10,14 @@ export default function DeterminateLinearProgress() { | |||
MuiLink: { | |||
styleOverrides: { | |||
root: { | |||
color: '#0068a9', // blue | |||
color: '#fbca04', // orange |
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.
change to orange color to make the regression obvious
Would be nice to have it merged :) Then could actually update to new version as right now all link colors are wrong and do not take account theme style overrides |
For sure, I am waiting for the review. I think it can be merged today (usually, we release the package on Monday). |
@@ -149,7 +150,7 @@ const Link = React.forwardRef(function Link(inProps, ref) { | |||
...props, | |||
// It is too complex to support any types of `sx`. | |||
// Need to find a better way to get rid of the color manipulation for `textDecorationColor`. | |||
color: (typeof sx === 'function' ? sx(theme).color : sx?.color) || color, | |||
color: (typeof sxColor === 'function' ? sxColor(theme) : sxColor) || color, |
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.
IMHO
<Link href="#unknown" color="#ff5252">
#ff5252
</Link>
and
<Link href="#unknown" sx={{ color: '#ff5252' }}>
#ff5252
</Link>
should behave differently. I would expect the former (color
prop) to set the color business logic of the component, e.g. the CSS color and CSS underline color, while the latter (sx
prop) to only set the CSS color. I think that this would be correct:
color: (typeof sxColor === 'function' ? sxColor(theme) : sxColor) || color, | |
color, |
Based on what I can see in https://www.argos-ci.com/mui/material-ui/builds/400. Anyway, nothing major, It's more that I feel we are overstepping a bit the scope responsibility of the sx
prop.
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.
Agree, I think it is too soon to add it. color
in sx
should only target CSS color property. I can open a PR to revert it before it is too late (it was introduced in the latest 5.6.1). @mnajdova What do you think?
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.
Agree, the keys inside the sx
prop should correspond to the CSS properties only
Closes #32172
Closes #32183
Root cause
The prop
color
(default asprimary
) is passed tosx
internally which has higher priority than style overrides. This PR check the instancecolor
prop before passing it tosx
.