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: Remove grid positioning attributes when you move a block outside of the grid container #63973

Closed
Tracked by #57478
noisysocks opened this issue Jul 26, 2024 · 0 comments · Fixed by #64186
Closed
Tracked by #57478
Assignees
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

Comments

@noisysocks
Copy link
Member

noisysocks commented Jul 26, 2024

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 is
  • style.layout.rowSpan - How many rows high the child is

Using 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 in innerBlocks, 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.

@noisysocks noisysocks changed the title We should remove columnStart, rowStart, etc. when you move a block outside of the grid container Grid: Remove grid positioning attributes when you move a block outside of the grid container Jul 26, 2024
@noisysocks noisysocks added [Type] Enhancement A suggestion for improvement. [Feature] Layout Layout block support, its UI controls, and style output. [Type] Task Issues or PRs that have been broken down into an individual action to take and removed [Type] Enhancement A suggestion for improvement. labels Jul 26, 2024
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Aug 2, 2024
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. [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
Projects
None yet
2 participants