-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[Grid] Fix Grid v1 spacing when using CSS variables #44663
[Grid] Fix Grid v1 spacing when using CSS variables #44663
Conversation
Netlify deploy previewhttps://deploy-preview-44663--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 makes the most sense. Delate the calculation to CSS if we can 👍, I like it.
Lol. 1 #40224 breaks Grid v1 with CSS variables I think it's why having clear scopes with clear https://www.notion.so/mui-org/Product-owners-836c72feffcc4cb2b735b51527e6991a?pvs=4#01db303c540643969c7274ef6c823ba5 is important. Tests help for sure scale the ownership, but they don't allow to be as fast and do as quality work with 3-4 people iterating on the logic, as 1 can.
We could solve this with a partial revert of https://github.com/mui/material-ui/pull/42574/files#r1632084146. This wasn't truly accurate. |
Summary
Closes: #44662
Sadly, we went back and forth in regressions with #40224, #42574 and #44376.
The issue
This latest regression is caused because
-calc(...)
values are not valid, see https://codepen.io/diegoandai/pen/qEWboqp. The Grid is outputting-calc(...)
margin values whencssVariables: true
:The solution
This PR fixes it by replacing
-calc(...)
withcalc(-1 * calc(...))
. It also replaces-<pixelValue>px
withcalc(-1 * pixelValue)
as I don't think it's worth it adding the logic to differentiate between cases inside the Grid.Before: https://stackblitz.com/edit/react-ziw5rb?file=Demo.tsx,package.json
After: https://codesandbox.io/p/sandbox/pull-44663-after-jvt2tj
Post mortem
As a post-mortem of the multiple regressions, what I think enabled them was not having enough tests with each PR to cover the cases being fixed.
What I don't like about this fix is that it also changes the implementation for users who are not using CSS variables. Although the result should be the same, I hope there are no edge cases to my approach. If there are an ideas for how to fix this without changing the functionality for non-CSS variables users, I'll be happy to refactor the solution.