gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Grid block: add "auto-fit" option

Open bradhogan opened this issue 2 years ago • 7 comments

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

  1. Add grid block (need grid experiment checked in gutenberg settings)
  2. Add three groups within the grid (so there are three columns)
  3. Select the grid block - set to "full width" then also update the width for the interior groups to "200px"
  4. View on desktop
  5. Notice the empty whitespace (does not fill entire section)
  6. If you change repeat(auto-fill, minmax(min(200px, 100%), 1fr)) to repeat(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

bradhogan avatar Dec 18 '23 20:12 bradhogan

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 avatar Dec 18 '23 21:12 jordesign

@jordesign in the admin menu, go to Gutenberg > Experiments > check to turn the grid block on (it's part of the Group block)

bradhogan avatar Dec 18 '23 22:12 bradhogan

Ah - thanks - the experimental grid block. Thanks for confirming.

jordesign avatar Dec 18 '23 22:12 jordesign

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.

tellthemachines avatar Jan 08 '24 02:01 tellthemachines

Yes, please, implement the auto-fit option to the (now stable) Grid layout 🙏🏻.

germanfrelo avatar Sep 30 '24 08:09 germanfrelo

+1000 for this, PLEASE 🙏 🙏 🙏

yankiara avatar Dec 12 '24 15:12 yankiara

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 use auto-fit every 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.

nextab avatar Mar 18 '26 16:03 nextab