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] Support customized breakpoints #31998

Merged

Conversation

boutahlilsoufiane
Copy link
Contributor

Fix #26369.

This fixes the problem of passing custom breakpoints as props to the component Grid, the TypeScript throws an error when we pass these dynamic props and that happens because we are not supporting custom breakpoints in TypeScript.

@mui-bot
Copy link

mui-bot commented Mar 26, 2022

Details of bundle changes

Generated by 🚫 dangerJS against 39dc30f

@boutahlilsoufiane boutahlilsoufiane changed the title Grid support customized breakpoints [Grid] support customized breakpoints Mar 26, 2022
@danilo-leal danilo-leal added the component: Grid The React component. label Mar 28, 2022
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Apr 8, 2022
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Apr 14, 2022
Copy link
Member

@mnajdova mnajdova left a comment

Choose a reason for hiding this comment

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

The changes look good, I've left one comment for a change that we need to revert. Could you please add tests for this behavior? You can add a test in the moduleAugmentation suite. You can call it something like gridCustomBreakpoints.spec.tsx

packages/mui-material/src/Grid/Grid.d.ts Outdated Show resolved Hide resolved
Copy link
Member

@mnajdova mnajdova left a comment

Choose a reason for hiding this comment

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

Ooops one more thing I almost forgot. You need to not propagate these props on the DOM node. We will need some kind of filtering of the props.

@boutahlilsoufiane
Copy link
Contributor Author

Hi @mnajdova, thanks a lot for your time, I will check the changes!

@boutahlilsoufiane
Copy link
Contributor Author

Hi @​mnajdova thanks a lot for taking the time to review the PR, could you please review it?

Copy link
Member

@mnajdova mnajdova left a comment

Choose a reason for hiding this comment

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

Great job! Overall looks good. I left few comments here and there :)

cc @hbjORbj you may be interested in this too.

packages/mui-material/src/Grid/Grid.js Outdated Show resolved Hide resolved
packages/mui-material/src/Grid/Grid.js Outdated Show resolved Hide resolved
packages/mui-material/src/Grid/Grid.js Outdated Show resolved Hide resolved
packages/mui-material/src/Grid/Grid.js Outdated Show resolved Hide resolved
@boutahlilsoufiane
Copy link
Contributor Author

Hi @mnajdova, ​thanks a lot for taking the time to clarify things, I appreciate your precious time. The comments are addressed!

Copy link
Member

@mnajdova mnajdova left a comment

Choose a reason for hiding this comment

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

One last comment from my side. Taggin @siriwatknp for a final review


return [
styles.root,
container && styles.container,
item && styles.item,
zeroMinWidth && styles.zeroMinWidth,
...resolveSpacingClasses(spacing, container, styles),
...spacingClasses,
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't make much sense, why spreading spacing classes here? Based on the logic inside resolveSpacingClasses if styles do not exists for the specific key, a class name is being added.

Not saying is a fault of this PR, but it is wrong. Maybe we should have two different functions, one for classes, and one for adding the styles overrides.

const slots = {
root: [
'root',
container && 'container',
item && 'item',
zeroMinWidth && 'zeroMinWidth',
...resolveSpacingClasses(spacing, container),
...spacingClasses,
Copy link
Member

Choose a reason for hiding this comment

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

We would use the classes util here only

packages/mui-material/src/Grid/Grid.js Outdated Show resolved Hide resolved
docs/src/components/pricing/FAQ.tsx Outdated Show resolved Hide resolved
Copy link
Member

@mnajdova mnajdova left a comment

Choose a reason for hiding this comment

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

LGTM cc @siriwatknp FYI

@mnajdova
Copy link
Member

mnajdova commented Jun 8, 2022

@boutahlilsoufiane what was this: 39dc30f ? 😅

@boutahlilsoufiane
Copy link
Contributor Author

Hi @mnajdova, thanks a lot for your time. Thanks for removing the code!

@mnajdova mnajdova added the new feature New feature or request label Jun 10, 2022
@mnajdova mnajdova merged commit acbc2af into mui:master Jun 10, 2022
@oliviertassinari oliviertassinari changed the title [Grid] support customized breakpoints [Grid] Support customized breakpoints Jun 11, 2022
@oliviertassinari
Copy link
Member

oliviertassinari commented Jun 11, 2022

This PR introduces a regression. It can be seen on https://mui.com/material-ui/react-grid/. It can be reproduced with:

<Grid key={12} />

Screenshot 2022-06-11 at 20 16 30

which is because of

key: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),

that is because of the changes inside Grid.js that get intercepted in a strange way by yarn proptypes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: Grid The React component. new feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Grid] Add support for new breakpoints
5 participants