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

Prevent single Columns blocks transforming into Columns. #43641

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions packages/block-library/src/columns/transforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,23 @@ const transforms = {
createBlocksFromInnerBlocksTemplate( innerBlocksTemplate )
);
},
isMatch: ( { length: selectedBlocksLength } ) =>
selectedBlocksLength &&
selectedBlocksLength <= MAXIMUM_SELECTED_BLOCKS,
isMatch: ( { length: selectedBlocksLength }, blocks ) => {
// If a user is trying to transform a single Columns block, skip
// the transformation. Enabling this functiontionality creates
// nested Columns blocks resulting in an unintuitive user experience.
// Multiple Columns blocks can still be transformed.
if (
blocks.length === 1 &&
blocks[ 0 ].name === 'core/columns'
) {
return false;
}

return (
selectedBlocksLength &&
selectedBlocksLength <= MAXIMUM_SELECTED_BLOCKS
);
},
},
{
type: 'block',
Expand Down