gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Grid Layout Improvements for 6.7

Open tellthemachines opened this issue 1 year ago • 13 comments

Part of Design Tools overview and Layout improvements.

The Grid layout type shipped in WP 6.3 and in WP 6.6 a new Grid variation for the Group block was stabilised, along with support for grid children spanning multiple columns and rows, and on-canvas resize handles.

What's this currently look like?

Under Gutenberg > Experiements, enable "Grid interactivity".

When a Grid block is set to Manual mode (in the block sidebar under Layout), it's now possible to drag and drop blocks into specific grid cells, as well as moving them up, down, left and right with the movers:

https://github.com/WordPress/gutenberg/assets/8096000/afe0fee0-375d-499e-8513-115a0192f843

Tasks

Needed before we remove experimental flag

  • [x] https://github.com/WordPress/gutenberg/pull/62777
  • [x] https://github.com/WordPress/gutenberg/pull/63391
  • [x] https://github.com/WordPress/gutenberg/pull/63464
  • [x] https://github.com/WordPress/gutenberg/pull/63395
  • [x] https://github.com/WordPress/gutenberg/pull/63333
  • [x] https://github.com/WordPress/gutenberg/pull/63394
  • [x] https://github.com/WordPress/gutenberg/issues/63275
  • [x] Fix miscellaneous bugs reported in https://github.com/WordPress/gutenberg/issues/62928
  • [x] https://github.com/WordPress/gutenberg/pull/63108
  • [x] https://github.com/WordPress/gutenberg/issues/62518
  • [x] https://github.com/WordPress/gutenberg/pull/62894
  • [x] #63973
  • [ ] #63976
  • [ ] https://github.com/WordPress/gutenberg/issues/64289

Needed for 6.7

  • [x] https://github.com/WordPress/gutenberg/issues/63279
  • [x] #63979
  • [ ] #63974
  • [ ] https://github.com/WordPress/gutenberg/issues/63965
  • [ ] https://github.com/WordPress/gutenberg/issues/63967
  • [ ] #63975
  • [ ] https://github.com/WordPress/gutenberg/issues/63966
  • [ ] #63978
  • [ ] https://github.com/WordPress/gutenberg/issues/62895
  • [ ] https://github.com/WordPress/gutenberg/issues/63969
  • [ ] https://github.com/WordPress/gutenberg/issues/63971
  • [ ] #64162
  • [ ] https://github.com/WordPress/gutenberg/issues/64285
  • [ ] https://github.com/WordPress/gutenberg/issues/64286
  • [ ] https://github.com/WordPress/gutenberg/issues/64287
  • [ ] https://github.com/WordPress/gutenberg/issues/64288
  • [ ] https://github.com/WordPress/gutenberg/issues/64383

Nice to have

  • [ ] #63977
  • [ ] https://github.com/WordPress/gutenberg/issues/63968
  • [ ] https://github.com/WordPress/gutenberg/issues/63970
  • [ ] This feature might benefit from a more intuitive drag and drop, using longpress for example.
  • [ ] Auto-adjusting option that resizes grid according to its number of children (example applied to Gallery block)
  • [ ] Consider adding a minimum row height control.

tellthemachines avatar Jan 02 '24 06:01 tellthemachines

Quick sketch showing what a next iteration of grid might look like. Keeping in mind we still want to push layout forward in general including generic width/height options via https://github.com/WordPress/gutenberg/pull/53455.

image

Children fill width/height of column/row by default. I'm showing width/height controls just to illustrate they are different to span and can be included in the separate layout work. We can start with inspector controls and work our way towards on canvas manipulation, including start/end of grid items which can lead to overlapping blocks.

SaxonF avatar Jan 03 '24 07:01 SaxonF

Some free flowing thoughts.... Can we have one grid system that can be used by the Cover block, Group block. Columns block etc? (with some minor adjustments where needed.)

I say this as the "Change Content Position" inside the Cover block can use a nice upgrade. Having one grid system used between the various blocks would be very helpful.

In relation to grid. It would also be helpful to have an icon to turn on/off helper lines. Somewhat like InDesign/Photoshop one can turn on the grid lines to see how things line up.

paaljoachim avatar Jan 17 '24 09:01 paaljoachim

Thinking through what's needed here in light of #58539:

  • Grid children spanning multiple columns with the "auto" grid setting will need some sort of responsive behaviour so the grid doesn't break at smaller breakpoints (see suggestion)
  • The ability to position a child in/starting from a specific column or row (this should only work for the "manual" grid, given that with the "auto" grid column number varies depending on container width) - could be an "offset" input control?
  • Positioning grid items with drag and drop: the drop indicators when dragging over a grid block could show a block dropzone over empty columns.
  • Changing column and row span of grid items with drag to resize
  • Regarding subgrids: they can be made to work for direct descendants of a block with grid layout fairly easily.

it would be interesting to experiment with making the grid configuration match theme content and wide width settings

I played around with this a bit and it doesn’t seem possible to match the current behaviour of content and wide layouts with grid. In any case there’s no real gain in replacing the content sizing and alignment logic with a grid-based implementation.

tellthemachines avatar Feb 05 '24 05:02 tellthemachines

  • Positioning grid items with drag and drop: the drop indicators when dragging over a grid block could show a block dropzone over empty columns.
  • Changing column and row span of grid items with drag to resize

👋 I'm going to try and build a prototype of this stuff.

noisysocks avatar Feb 07 '24 23:02 noisysocks

@tellthemachines, @SaxonF and I are actively working on this. I updated the issue to be an overview issue and added a few tasks that we've discussed.

https://github.com/WordPress/gutenberg/pull/59052 added a new Grid interactivity experiment which you can enable in Gutenberg → Experiments. Currently you can visualise where the grid cells are when you select a Grid block and use a resize handle to set the span of a block within the Grid. I'm looking into drag and drop now.

noisysocks avatar Feb 27 '24 05:02 noisysocks

Update:

A lot of this feature has involved synchronous back-and-forth chat so in an effort to make those conversations more transparent I've create a channel in the w.org slack called #feature-grid.

I've been experimenting lots with drag and drop in https://github.com/WordPress/gutenberg/pull/59490 and in https://github.com/WordPress/gutenberg/pull/61025. There's some good progress but still a lot of discovery to do and questions to answer.

@tellthemachines and I both have a few commitments coming up, and @SaxonF is now on parental leave, so we're running out of time to get things polished for WP 6.6.

With that in mind @tellthemachines and I are going to focus on shipping:

  • Column / row span attributes
  • The grid line overlay
  • Resize handles

Tasks to do:

  • [x] Move those items out of the experimental flag
  • [x] Implement design that is in this video
  • [x] Maybe: Make resizing work towards the top/left https://github.com/WordPress/gutenberg/pull/60986
  • [x] Hide duplicate resize controls in e.g. image block https://github.com/WordPress/gutenberg/pull/61603
  • [x] Fix resize bug in site editor
  • [x] https://github.com/WordPress/gutenberg/issues/61633

noisysocks avatar Apr 30 '24 05:04 noisysocks

Nice progress on this @tellthemachines and @noisysocks!

I'm not sure if it's related to #60986 or the site editor resize bug, but while testing in trunk in the post editor, I noticed that the boundaries for the resizeable box aren't always reliable. In the below Grid, the last item in particular displayed a bit of weirdness in its width while dragging. Also, sometimes when dragging an item to the right, the box seems to be getting limited horizontally. Here's a screengrab:

https://github.com/WordPress/gutenberg/assets/14988353/17cfe54f-68b1-4f32-a260-4c5785d75a51

Grid markup
<!-- wp:group {"layout":{"type":"grid","columnCount":3,"minimumColumnWidth":null,"rowCount":"3"}} -->
<div class="wp-block-group"><!-- wp:paragraph {"style":{"layout":{"columnSpan":1,"rowSpan":1}},"backgroundColor":"accent-4"} -->
<p class="has-accent-4-background-color has-background">A paragraph</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph {"backgroundColor":"accent-4"} -->
<p class="has-accent-4-background-color has-background">Another paragraph</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph {"backgroundColor":"accent-4"} -->
<p class="has-accent-4-background-color has-background">Another one</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph {"style":{"layout":{"columnSpan":1,"rowSpan":1}},"backgroundColor":"accent-4"} -->
<p class="has-accent-4-background-color has-background">A paragraph</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph {"backgroundColor":"accent-4"} -->
<p class="has-accent-4-background-color has-background">Yet another</p>
<!-- /wp:paragraph --></div>
<!-- /wp:group -->

<!-- wp:paragraph -->
<p></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p></p>
<!-- /wp:paragraph -->

Let me know if you'd prefer I open an issue, and I can put one up tomorrow.

andrewserong avatar May 13 '24 06:05 andrewserong

@andrewserong I can't reproduce that in the post editor, only in the site editor, so it seems like it's the site editor bug (I'm not sure where it was reported, maybe in one of the PRs? but pretty sure that's the bug). Were you able to reproduce it in the post editor too? I haven't managed to do so on the latest trunk.

Edit: even in the site editor, the behaviour changes depending on whether the block was newly-added, or if the page has been reloaded after adding the block (it's still buggy after reload, just not as buggy)

tellthemachines avatar May 13 '24 07:05 tellthemachines

Were you able to reproduce it in the post editor too? I haven't managed to do so on the latest trunk.

Yes, I can reproduce in the post editor, but only when it's iframed. I.e. if I set Custom Fields to be visible it's fine, but not if they're not. I also ran into an issue where after interacting with the resizer for a while the post editor freezes (this is while not iframed):

image

Specifically the freezing appears to happen when I go to resize the last block and drop it back to very near the edge of the block:

https://github.com/WordPress/gutenberg/assets/14988353/a6018c25-7721-4097-8c7a-58c5c4067f49

Could there be an infinite loop or memory leak somewhere?

I've opened up a separate issue over in #61633 in case that helps keep the conversation contained 🙂

andrewserong avatar May 13 '24 23:05 andrewserong

Quick update for anyone following along this tracking issue: with the outstanding interactivity issues now addressed, the grid visualiser and resizers have been stabilised for Gutenberg 18.4, which means folks will be able to try out dragging Grid child blocks to set column and row span, without having to activate the interactivity experiment in the plugin. There are still some pending visual enhancements to explore, but I believe it looks like the feature should now be in the overall shape that it’s intended to be for WP 6.6.

andrewserong avatar May 14 '24 23:05 andrewserong

Update on grid work

In the past few weeks, most of the functionality intended to ship in 6.7 has been put in place behind the "grid interactivity" experiment flag:

  • Manual mode has been updated to always explicitly place blocks in a column/row, allowing any block to be moved to any grid cell. This also allows blocks to overlap or partially overlap (in the case of blocks that take up multiple grid cells).

  • It's now possible to specify both "Columns" and "Minimum column width" in both Auto and Manual modes. Specifying "Columns" and "Minimum column width" together allows grids to have a maximum column count and resize to less columns in smaller areas.

  • This means that the difference between Auto and Manual modes is now only in the placement of grid children:

    • Auto mode relies on auto-placement, so it's not possible to specify a grid cell for a particular block. New blocks are placed in the first available cell in the grid.
    • In Manual mode, all blocks are manually placed, so new blocks can be placed in a specific cell, and there can be empty cells in the middle of the grid. In this mode, block appenders are shown on hover/focus in each empty cell and blocks can be dragged and dropped into any cell, whether empty or full.

Next steps

Testing of these new features is highly appreciated!

There are a few small bugs and enhancements outstanding (see list in issue description), and once they are fixed, the new Manual grid should be in a good place to stabilize in the plugin.

There's also the alignments feature which would be nice to have in 6.7, but needs some design work first: https://github.com/WordPress/gutenberg/issues/62895

tellthemachines avatar Jul 12 '24 05:07 tellthemachines

Did a bit of housekeeping here 🧹

I've:

  • asked a couple of my colleagues for feedback on this feature and opened a few new issues with what they wrote back to me.
  • converted every To do item in the issue description into an issue containing a brief explanation of the task.
  • triaged the issue description into Needed before we remove experimental flag, Needed for 6.7, and Nice to have.

My hope is that it's now much clearer how other contributors can help with development. @tellthemachines is away until October, so any help is much appreciated 🙂

noisysocks avatar Jul 26 '24 05:07 noisysocks

Very unlikely this will make it into 6.7 – I've punted it in the project board.

noisysocks avatar Aug 29 '24 00:08 noisysocks

Could anyone provide additional feedback on #64995, which solves one problem in RTL languages?

t-hamano avatar Sep 10 '24 06:09 t-hamano