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

[mui-system][Grid] Remove disableEqualOverflow by using gap #42526

Merged
merged 9 commits into from
Jun 10, 2024

Conversation

DiegoAndai
Copy link
Member

Part of #35993

POC to refactor the Grid component using the gap CSS property. This removes the scroll bug that disableEqualOverflow was used to solve. With the removal of disableEqualOverflow, we can remove the use of context and move closer to a RSC compatible Grid.

@DiegoAndai DiegoAndai self-assigned this Jun 4, 2024
@DiegoAndai DiegoAndai added component: Grid The React component. package: system Specific to @mui/system labels Jun 4, 2024
@mui-bot
Copy link

mui-bot commented Jun 4, 2024

Netlify deploy preview

@material-ui/core: parsed: -0.10% 😍, gzip: -0.15% 😍
@material-ui/system: parsed: -0.72% 😍, gzip: -0.73% 😍
@mui/joy/Grid: parsed: -0.83% 😍, gzip: -0.88% 😍
Unstable_Grid2: parsed: -0.95% 😍, gzip: -0.92% 😍
@mui/joy: parsed: -0.12% 😍, gzip: -0.14% 😍

Bundle size report

Details of bundle changes (Toolpad)
Details of bundle changes

Generated by 🚫 dangerJS against 132f89b

@mnajdova mnajdova requested a review from siriwatknp June 5, 2024 09:50
@mnajdova
Copy link
Member

mnajdova commented Jun 5, 2024

I like this direction, also keeping the APIs similar between the two Grid components sounds awesome 👌 We should document the breaking change if we decide to go with it!

@DiegoAndai DiegoAndai changed the title [mui-system][Grid] Remove disableEqualOverflow from by using gap [mui-system][Grid] Remove disableEqualOverflow by using gap Jun 5, 2024
@DiegoAndai
Copy link
Member Author

DiegoAndai commented Jun 5, 2024

There are some style-breaking changes we should discuss. The previous approach of using a negative margin caused some artifacts that are now being fixed but will be perceived as breaking from users that have already adapted to the artifacts. These are reflected on the Argos failing tests so I'll group them and discuss them here:


A. Grid is contained inside parent's padding

Previusly, because of the negative margin, the Grid overflowed the parent's padding:

Screenshot 2024-06-05 at 15 27 18

Now, the Grid doesn't overflow:

Screenshot 2024-06-05 at 15 27 45

This is what removes the need for disableEqualOverflow (and thus React context), so I think we should accept the change, but we should know that it will change layouts as now padding affects the Grid differently. This is what causes a lot of the Argos failures:

But it also causes the scroll fix:

Here's the fixed demo: https://deploy-preview-42526--material-ui.netlify.app/material-ui/react-grid2/#disable-the-scrollbar

B. Spacing is no longer considered inside the Grid's box

Changing from padding to gap for the spacing implementation causes this space not to be included in the Grid's box anymore, as it's no longer padding. This causes the following Argos failures:

IMO we should accept this change, as gap is the better alternative for this implementation. These examples are still viable but using spacing={0}. You can see the effect of this in this demo: https://deploy-preview-42526--material-ui.netlify.app/material-ui/react-grid2/#full-border

Remaining Argos failures

I'm not sure what caused these Argos failures:

But seems like the original implementation is overflowing, so this change looks like an improvement.

Also don't know what happened with this one: https://app.argos-ci.com/mui/material-ui/builds/28714/93537251. It looks good in the preview: https://deploy-preview-42526--material-ui.netlify.app/joy-ui/react-aspect-ratio/#variants

And the dashboard template is showing an error as well: https://app.argos-ci.com/mui/material-ui/builds/28714/93537202. But it looks ok in the preview: https://deploy-preview-42526--material-ui.netlify.app/material-ui/getting-started/templates/dashboard/

Types check failure

The types check failure is because I haven't yet removed the disableEqualOverflow prop from the Prevent Scroll demo. This demo should be removed if we accept this PR, but I'm keeping it for now so we can check that the removal of the prop is working as expected and the scroll bar is not present.


@mnajdova @siriwatknp @aarongarciah above is the breakdown of the breaking changes ☝🏼.

I think we should accept these and document them as breaking changes, but I want to know if you're on board. I don't see a way of using gap and keeping the previous spacing artifacts without introducing technical debt. IMO, this is the way we would've implemented it if we were able to use gap back then.

If you're on board, I'll document the breaking changes and mark this PR for review.

@siriwatknp
Copy link
Member

@aarongarciah
Copy link
Member

@DiegoAndai I think the changes make sense:

  • 👍 getting rid of negative margins (auto-contained grid)
  • 👍 developers need to explicitly add padding to individual items and explicitly remove the spacing (gap)

This maps better with how developers work with layout these days: flex/grid + gap 👌

Not sure if I'm missing additional issues in the thread that @siriwatknp linked, but it looks like all of it is covered in your explanation.

@siriwatknp
Copy link
Member

Thanks for the detailed explanation. We can accept this breaking change because it is a part of the v6 goal, to transition to Pigment CSS 👏

@DiegoAndai DiegoAndai marked this pull request as ready for review June 6, 2024 20:25
@DiegoAndai
Copy link
Member Author

@siriwatknp, this is ready for review 🙌🏼

I've added a section to the migration guide explaining the breaking changes: https://deploy-preview-42526--material-ui.netlify.app/material-ui/migration/migration-v5/#grid-v2-unstable-grid

Please go through the Argos changes and review if everything makes sense to you or if something is wrong.

Copy link
Contributor

@danilo-leal danilo-leal left a comment

Choose a reason for hiding this comment

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

Love the before/after images 👌

docs/data/material/migration/migration-v5/migration-v5.md Outdated Show resolved Hide resolved
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.

image

👍 Love it!

@DiegoAndai DiegoAndai merged commit 9ec0da8 into mui:next Jun 10, 2024
22 checks passed
@DiegoAndai DiegoAndai deleted the poc-grid-with-gap branch June 10, 2024 20:08
mnajdova pushed a commit to mnajdova/material-ui that referenced this pull request Jun 12, 2024
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
breaking change component: Grid The React component. package: system Specific to @mui/system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants