You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow Group blocks to transform into Cover blocks #30445
Good First IssueAn issue that's suitable for someone looking to contribute for the first time[Block] CoverAffects the Cover Block - used to display content laid over a background image[Block] GroupAffects the Group Block (and row, stack and grid variants)[Status] In ProgressTracking issues with work in progress[Type] EnhancementA suggestion for improvement.
You can't transform a Cover block into a Group block, only wrap a group block around the Cover block (This is possible for every block). You can use ungroup to remove the group around the block.
If we add the ungroup option to the transfer dropdown, we should build for all blocks, not just for the cover block.
I personally can't find much value in this transform, as Cover block needs user input to initialize and we'll have to make arbitrary choices about them. This can confuse users I think. Maybe by having extra checks for having an Image block in group's InnerBlocks and use that as the Cover's background 🤔 ?
Even that would need more changes since the isMatch from transforms API would need to be extended to provide the innerBlocks as well and not only the attributes.
I'm not sure if it's better for me to reply here or in the PR.
It's worth noting that this does not require user input if there is an existing background of some sort, but I hear you.
I'm mostly thinking it might be easier for a user to take this path, if they started out with a group, and decided to move to a cover block. Could also only allow the transform when that's the case, but that blocks users from migrating a group when they intend to add an image to the background.
I thought about adding something to migrate an image from innerBlocks, but I also wonder if that would be confusing, since it'd be difficult to know which image to pick, and could generate user surprise. I suppose with the previews, it would show the user what would happen, though. I can try to put together a path of some sort to do that, if folks think it'd be helpful.
Perhaps we only make this available for Group Blocks that have a solid color background set? Then there's a clear 1:1 cover block equivalent to transition to. (Once #14744 is resolved, there should be more possibilities here too).
Good First IssueAn issue that's suitable for someone looking to contribute for the first time[Block] CoverAffects the Cover Block - used to display content laid over a background image[Block] GroupAffects the Group Block (and row, stack and grid variants)[Status] In ProgressTracking issues with work in progress[Type] EnhancementA suggestion for improvement.
Activity
Soean commentedon Apr 12, 2021
You can't transform a Cover block into a Group block, only wrap a group block around the Cover block (This is possible for every block). You can use
ungroupto remove the group around the block.If we add the ungroup option to the transfer dropdown, we should build for all blocks, not just for the cover block.
ntsekouras commentedon Apr 16, 2021
I personally can't find much value in this transform, as
Coverblock needs user input to initialize and we'll have to make arbitrary choices about them. This can confuse users I think. Maybe by having extra checks for having an Image block in group's InnerBlocks and use that as the Cover's background 🤔 ?Even that would need more changes since the
isMatchfromtransforms APIwould need to be extended to provide theinnerBlocksas well and not only the attributes.Reference: https://developer.wordpress.org/block-editor/reference-guides/block-api/block-transforms/#block
getsource commentedon Apr 16, 2021
I'm not sure if it's better for me to reply here or in the PR.
It's worth noting that this does not require user input if there is an existing background of some sort, but I hear you.
I'm mostly thinking it might be easier for a user to take this path, if they started out with a group, and decided to move to a cover block. Could also only allow the transform when that's the case, but that blocks users from migrating a group when they intend to add an image to the background.
I thought about adding something to migrate an image from
innerBlocks, but I also wonder if that would be confusing, since it'd be difficult to know which image to pick, and could generate user surprise. I suppose with the previews, it would show the user what would happen, though. I can try to put together a path of some sort to do that, if folks think it'd be helpful.kjellr commentedon Apr 16, 2021
Perhaps we only make this available for Group Blocks that have a solid color background set? Then there's a clear 1:1 cover block equivalent to transition to. (Once #14744 is resolved, there should be more possibilities here too).
ntsekouras commentedon Apr 16, 2021
Handling
Groupblocks that have background/gradient should work well with the current APIisMatch. Agreed.Also I'm not aware if we can extract the theme's main background color programmatically to set as
backgroundtoCoverif not one is set..kjellr commentedon Apr 16, 2021
Yeah, I'm not sure that we can. Though it might get easier to do that if the theme's defined a background via theme.json.
getsource commentedon Apr 23, 2021
Updated the PR to only offer transformation to cover when a background color or gradient is available in the Group block.