Skip to content
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 support for CSS variables #42574

Merged
merged 3 commits into from
Jun 9, 2024

Conversation

oliviertassinari
Copy link
Member

@oliviertassinari oliviertassinari commented Jun 8, 2024

The Grid is broken when using CSS variables, the regression was introduced in #40224 (visible on the description of that PR).

Before

-calc( doesn't work

SCR-20240608-roiu

https://next--material-ui.netlify.app/core/

SCR-20240608-rnio

After

SCR-20240608-rogm

https://deploy-preview-42574--material-ui.netlify.app/core/

SCR-20240608-rnor

Now, I imagine that during v6 lifecycle we will deprecate https://mui.com/material-ui/react-grid/ for https://mui.com/material-ui/react-grid2/. But first, we will need to migrate all our marketing pages to use the new grid. And even once we do, the deprecated version should continue to work with CSS variables so developers can migrate to it.

@oliviertassinari oliviertassinari added bug 🐛 Something doesn't work component: Grid The React component. regression A bug, but worse labels Jun 8, 2024
@mui-bot
Copy link

mui-bot commented Jun 8, 2024

Netlify deploy preview

https://deploy-preview-42574--material-ui.netlify.app/

Bundle size report

Details of bundle changes (Toolpad)
Details of bundle changes

Generated by 🚫 dangerJS against 1f84b37

Comment on lines -28 to -34
function getOffset(val) {
const parse = parseFloat(val);
if (Number.isNaN(parse)) {
return val;
}
return `${parse}${String(val).replace(String(parse), '') || 'px'}`;
}
Copy link
Member Author

@oliviertassinari oliviertassinari Jun 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we can drop this since we have this new constraint: https://mui.com/material-ui/migration/v5-style-changes/#%E2%9C%85-remove-px-suffix.

It seems impossible to have values without units:

return typeof output === 'number' ? `${output}px` : output;
, so calc will always work.

@@ -155,6 +155,36 @@ describe('system spacing', () => {
expect(output).to.deep.equal({ padding: '-2em' });
});

it('should support CSS variables single value', () => {
Copy link
Member Author

@oliviertassinari oliviertassinari Jun 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel these tests were missing a bit from #40224. There are present, but higher up in the abstraction chain. Not that important though;

Copy link
Member

@siriwatknp siriwatknp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Thanks for the fix.

@siriwatknp siriwatknp merged commit cf2b165 into mui:next Jun 9, 2024
19 checks passed
@oliviertassinari oliviertassinari deleted the fix-grid-regression branch June 9, 2024 09:37
joserodolfofreitas pushed a commit to joserodolfofreitas/material-ui that referenced this pull request Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: Grid The React component. regression A bug, but worse
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants