Grid: Remove grid positioning attributes when you move a block outside of the grid container #63973
Labels
[Feature] Layout
Layout block support, its UI controls, and style output.
[Status] In Progress
Tracking issues with work in progress
[Type] Task
Issues or PRs that have been broken down into an individual action to take
When a Grid block is set to Manual mode, children of the grid are positioned according to attributes on each child block.
There are four:
style.layout.columnStart
- Column that the child begins at (x position)style.layout.rowStart
- Row that the child begins at (y position)style.layout.columnSpan
- How many columns wide the child isstyle.layout.rowSpan
- How many rows high the child isUsing drag and drop, the movers, resize handles, etc. will adjust these attributes.
If a child is added to a grid and doesn't already contain these attributes, they are added by a hook called
useGridLayoutSync
.If the grid is switched from Manual mode to Auto mode,
useGridLayoutSync
will remove all of these attributes on the children.We need to implement logic that removes these attributes if the child block is moved out of the grid container. Right now, if you drag and drop a block from inside a grid to some place else, and then view the source, you'll see pointless
columnStart
etc. attributes on that block.One way to do this might be to update
useGridLayoutSync
to keep a list of children it knows about. Then, when a child it knows about is no longer ininnerBlocks
, but that child is still in the block editor store, we can assume it has been moved outside of the grid and that we should remove the layout attributes.The text was updated successfully, but these errors were encountered: