Closed ImanMahmoudinasab closed 3 years ago
Note that it doesn't reproduce in v5: https://codesandbox.io/s/box-issue-with-undefined-forked-y4f2g?file=/demo.js.
I've started investigating the issue to fix it. Any comment is welcomed.
I have opened a related issue on JSS: https://github.com/cssinjs/jss/issues/1445 as it could be one great resolution path.
We also had a close issue #24182 that was about developers doing: -theme.spacing(1)
which returns NaN, they should do theme.spacing(-1)
instead.
@ImanMahmoudinasab I've got the same error. To reproduce:
Set calculated property to a class: paddingLeft: props => theme.spacing(2 * (props.level - 1))
Use that class with useStyles(undefined)
.
I do not really know how px
function was implemented, but it throws an exception if NaN
is passed as an argument to it.
Also, possibly theme.spacing
function must not return NaN
instead of undefined
.
@oliviertassinari Also, I'd like to laugh with you on this: typeof NaN
is number
. Not a number is a number. Very nice :)
@lichkessel I'm taking care of the spacing(undefined) => NaN
transformation happening in the system in #24527, it's wrong.
Regarding theme.spacing(NaN) => NaN
I think that it's expected, and should be fixed in https://github.com/cssinjs/jss/issues/1445.
I don't know if this is related but we are experiencing something similar with users that upgraded to Chrome 88.
This issue for us seems to be related <Dialog />
https://material-ui.com/api/dialog/
@lichkessel I'm taking care of the
spacing(undefined) => NaN
transformation happening in the system in #24527, it's wrong.Regarding
theme.spacing(NaN) => NaN
I think that it's expected, and should be fixed in cssinjs/jss#1445.
Maybe it is worth to silently fall back to undefined
value everywhere we do not know what value is passed as a parameter ? At the same time I doubt it could be implemented ad-hoc since this is a policy and I'm not sure it is common for material-ui.
The issue with the Box is fixed in #24527. It will be released soon or later. Regarding the other cases, make sure you are not providing NaN
as a CSS value. please continue the discussion on https://github.com/cssinjs/jss/issues/1445 (the best place to fix the root cause)
If you find a place where the NaN is generated from Material-UI, and you have a reproduction to prove it like it was the case with the Box in this issue (#24519), please open a new issue.
thanks for making this issue @ImanMahmoudinasab, and @oliviertassinari for your comments. it helped my team figure out our error. hopefully this thread will come up for others on Google as more people update Chrome and notice it affecting them
I don't know if this is related but we are experiencing something similar with users that upgraded to Chrome 88.
This issue for us seems to be related
<Dialog />
https://material-ui.com/api/dialog/
I am also getting this bug on production right now, not fixed with the patch too.
Hi @Gurmindermultani, we managed to put a hotfix out for this by overwriting the default paperWidthXs
like this:
createMuiTheme({
...
overrides: {
MuiDialog: {
paperWidthXs: { maxWidth: false },
},
},
})
Not sure if this will help in your case, but it might help with you guys finding a solution.
Not sure if this will help in your case, but it might help with you guys finding a solution.
@GearoidCollins Probably because Math.max('10px', 10) // NaN
. We assume that theme.breakpoints.values
are unitless values.
How can this thread be closed. The issue hasn't been resolved yet.
Current Behavior 😯
Setting
undefined
value to the margin, padding,... props of aBox
component would throw the following exception. This issue only is reproducible on chrome 88.Expected Behavior 🤔
Should ignore
undefined
value for props.Steps to Reproduce 🕹
https://codesandbox.io/s/box-issue-with-undefined-forked-hxp13