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: Swap the position of grid items when they are re-arranged in the List View? #63974

Open
Tracked by #57478
noisysocks opened this issue Jul 26, 2024 · 3 comments
Open
Tracked by #57478
Labels
[Feature] Layout Layout block support, its UI controls, and style output. [Type] Discussion For issues that are high-level and not yet ready to implement.

Comments

@noisysocks
Copy link
Member

noisysocks commented Jul 26, 2024

When using a Grid block set to Manual mode, you can drag and drop grid items to arbitrary cells which updates the columnStart and rowStart of that block. When this happens we also change the block's position in the block list (grid.innerBlocks) so that the DOM order of the blocks roughly matches the visual order.

We don't currently do this the other way around though. If you change the order of the Grid block's children using List View, only the markup order will change (useful for stacking!) and the blocks won't visually move around. This could be confusing.

I have three ideas:

1) We could do nothing.

List View would be for solely changing the DOM order of the grid's children, which is how you'd control which grid items are stacked on top of other grid items.

2) We could disable List View.

If we did not allow drag-and-drop-to-reorder in List View then this confusing interaction would go away. We'd need a new way of controlling which grid items are stacked on top of other grid items, though. Potentially we could add "Bring to front" and "Send to back" controls which are popular in lots of other editors. Related to #63971.

3) We could write logic that swaps the visual position of blocks when their order changes.

Say you had a block tree like this:

  • Grid
    • A
    • B
    • C
    • D

If the user re-orders D to be in between A and B then we could write logic that swaps the columnStart and rowStart attributes like so:

  • D takes B's position attributes
  • B takes C's position attributes
  • C takes D's position attributes
@noisysocks noisysocks changed the title [discussion: maybe this isn’t necessary, or maybe List View should just be disabled] Handle grid items being re-arranged in list view (currently dragging and dropping in list view inside a manual grid causes markup to shift but blocks to visually remain in place) Grid: Swap the position of grid items when they are re-arranged in the List View? Jul 26, 2024
@noisysocks noisysocks added [Type] Enhancement A suggestion for improvement. [Feature] Layout Layout block support, its UI controls, and style output. [Type] Discussion For issues that are high-level and not yet ready to implement. and removed [Type] Enhancement A suggestion for improvement. labels Jul 26, 2024
@talldan
Copy link
Contributor

talldan commented Aug 1, 2024

Throwing ideas around, another option is that you could have some kind of virtual grouping of the blocks in List View into cells.

E.g.

  • Grid
    • Cell (1,1)
      • Block A
      • Block B
    • Cell (1,4)
      • Block C

I'm not sure how this would be achievable without an inner block, but from a UI perspective it allows the user to drag between other (occupied) cells, change the z-index, and the blocks would also naturally have a DOM order matching the visual order.

I imagine it would only show the occupied cells in List View, otherwise it'd be very noisy.

@noisysocks
Copy link
Member Author

That's a cool idea!

I think it will be clearer which of these options we should explore once we get a bit more usage and feedback. Right now I don't know what folks are expecting when it comes to the List View.

@talldan
Copy link
Contributor

talldan commented Aug 2, 2024

Maybe I'm thinking too much about blocks as being neat things that fit into cells, whereas in reality the blocks can be arranged and overlap in interesting ways which will be harder to represent in List View the way I presented above. I'll keep thinking about it though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Layout Layout block support, its UI controls, and style output. [Type] Discussion For issues that are high-level and not yet ready to implement.
Projects
None yet
Development

No branches or pull requests

2 participants