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 "auto" behavior to match natural width of its content #27514

Merged

Conversation

aaronlademann-wf
Copy link
Contributor

@aaronlademann-wf aaronlademann-wf commented Jul 29, 2021

Problem

In #11804, support for the "auto" value was added to props like xs, sm et. al.

This prop value causes the MUI grid to work just like Bootstrap's grid "auto" setting most of the time, with a few exceptions:

  1. flex-shrink remains set to 1, which means the item will not always remain sized based on the "natural" width of its contents like users expect.
  2. width: 100% is still applied when using the "auto" setting on a nested Grid container items (<Grid container item xs="auto" />), which causes the item to not be sized based on the "natural" width at all.

Proposed Solution

Add flexShrink: 0 and width: auto when a breakpoint size is set to "auto" so that MUI's grid behaves in a way that is truly "auto" - in the sense that it scales to accommodate the natural width of its content.

I realize this constitutes a potentially breaking visual change for consumers, but 5.0 seems like a good time to include it!

Thank you for considering the change!

Preview: https://deploy-preview-27514--material-ui.netlify.app/components/grid/#variable-width-content

@mui-pr-bot
Copy link

mui-pr-bot commented Jul 29, 2021

Details of bundle changes (experimental)

Generated by 🚫 dangerJS against aad40ce

@oliviertassinari oliviertassinari added component: Grid The React component. breaking change new feature New feature or request bug 🐛 Something doesn't work and removed new feature New feature or request labels Aug 8, 2021
@oliviertassinari oliviertassinari changed the title [Grid] Align "auto" size behavior with bootstrap (variable width content) [Grid] Fix "auto" behavior to natural width of its content Aug 8, 2021
@oliviertassinari oliviertassinari changed the title [Grid] Fix "auto" behavior to natural width of its content [Grid] Fix "auto" behavior to match natural width of its content Aug 8, 2021
@oliviertassinari oliviertassinari merged commit d19207a into mui:next Aug 8, 2021
@oliviertassinari
Copy link
Member

@aaronlademann-wf Great work, the description and changes have been well structured

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change bug 🐛 Something doesn't work component: Grid The React component.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants