Grid block: add "auto-fit" option
Description
Running into an issue when using the grid block and seems this would be a quick fix. Rather than using auto-fill in the grid-templates-column if we switch to auto-fit, seems to work better to help those columns fill the space.
Step-by-step reproduction instructions
- Add grid block (need grid experiment checked in gutenberg settings)
- Add three groups within the grid (so there are three columns)
- Select the grid block - set to "full width" then also update the width for the interior groups to "200px"
- View on desktop
- Notice the empty whitespace (does not fill entire section)
- If you change
repeat(auto-fill, minmax(min(200px, 100%), 1fr))torepeat(auto-fit, minmax(min(200px, 100%), 1fr))in the console, you'll see it fixes the issue.
Screenshots, screen recording, code snippet
https://soapbox.wistia.com/videos/1IWnsyoL8e
Environment info
- wp 6.4.2
- gutenberg 17.2.3
- mac sonoma
- chrome
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
Thanks for the report @bradhogan - I'm unclear what block you're referring to by the 'Grid' block as that doesn't sound like one of the Core Gutenberg blocks. Could you please tell me a little more?
@jordesign in the admin menu, go to Gutenberg > Experiments > check to turn the grid block on (it's part of the Group block)
Ah - thanks - the experimental grid block. Thanks for confirming.
Thanks for creating this issue! The use of auto-fill was deliberate, because a single item or two items in a grid shouldn't always stretch to fill their whole container. The intention is to make this behaviour configurable in the future, but to start with auto-fill was chosen as a default so that the width of contents never varies too much from the defined minimum width.
I'll leave this open and re-label it as an enhancement to add auto-fit as an option.
Yes, please, implement the auto-fit option to the (now stable) Grid layout 🙏🏻.
+1000 for this, PLEASE 🙏 🙏 🙏
As developers, we have to deal with all kinds of different web designs. Personally, I haven't come across a grid-like design that requires
auto-fill(showing gaps where more space is available), which means I can't use the Grid group variation for the websites I build for clients. Instead, I have to rely on adding a class to the block(s) and using custom CSS just to useauto-fitevery time, but doing it that, way clients can't configure things like the grid item min size…
+1 to everything spelled out here. I have yet to see a single example where auto-fill is "better" than auto-fit. How this hasn't been addressed in several years is super frustrating.