-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
[Typography] Apply font properties to typography inherit variant #33621
Conversation
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, thanks!
Netlify deploy previewhttps://deploy-preview-33621--material-ui.netlify.app/ @material-ui/core: parsed: +0.10% , gzip: +0.09% Bundle size report |
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.
There's a unit test failing. Would you mind taking a look at it?
The visual regression tests detected another issue. The This has worked fine before, so I wonder if it's related to the latest changes to Emotion support in the System (cc @garronej, @mnajdova). |
@michaldudak I don't think the problem is with the order of how things are defined, but how this variant is defined. In the demo that you linked, if you change the |
Thanks @mnajdova for figuring this out. I am on vacation so I wasn't able to look at it. |
@mnajdova Thanks, I'll take a deeper look at this, then. |
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 fixed the issue identified by the visual regression test mentioned in #33621 (comment). As @mnajdova pointed out in #33621 (comment), it was about how the variant
was fetched in the sx
prop implementation. The issue was that, after adding the missing inherit
variant in Typography
, the default theme mapping for typography fetched the whole inherit
variant object from createTypography when there was any CSS font property of inherit
value defined in the sx
prop.
I added a fix in 224fdaa along with a test in the sx
prop implementation. However, I wonder if there is a better way to fix this. Perhaps there is something we can do in the Typography
component level instead of the sx
prop. But I also believe this is how we should do it, and it makes sense. (We can't change variant="inherit"
to something else, that would be a breaking change.)
I am approving it from my side, but DO NOT MERGE it until approved by @mnajdova or @michaldudak .
Addressed. See #33621 (review).
@ZeeshanTamboli I changed a bit the fix for the sx prop, by providing the necessary changes to the sx config instead of the |
let value = | ||
props.theme.typography?.[ | ||
`${prop}${ | ||
props[prop] === 'default' || props[prop] === 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.
Just curious, what is this props[prop] === prop
for? CSS property's value being equal to it's own property?
Nice! Makes sense. |
} | ||
|
||
if (!value) { | ||
value = propValue; |
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.
You've duplicated if statements here and on line 22
It appears that this PR may have broken the
But the code in this PR appears to only look for the prop without the
Here's a codesandbox that reproduces the issue: https://codesandbox.io/s/vibrant-brook-572rnc?file=/src/App.js You can verify that this is a regression by changing the version of Here's the documentation that refers to being able to use https://mui.com/system/getting-started/the-sx-prop/#typography |
I created an issue for this: #36542 |
Ensure that
Typography
components actually inherit font properties when inherit variant is used.Since the
Link
component is built on top of theTypography
component, this also fixes #32942.Before:
Now:
Fixes #32942