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

Block transforms: single Blocks shouldn't allow transforms to the same Block. Avoid block-specific behaviours #15996

Closed
getdave opened this issue Jun 5, 2019 · 4 comments
Assignees
Labels
[Block] Group Affects the Group Block [Feature] Block API API that allows to express the block paradigm.

Comments

@getdave
Copy link
Contributor

getdave commented Jun 5, 2019

Currently, the block transform logic prevents a single group block from being transformed into another core group block.

https://github.com/WordPress/gutenberg/pull/14908/files/5dd34524c2a6bdd81b399d959ad71636ef0c3501#diff-a5c77b070da74373cd1d937dee3a77eaR150

In pursuit of avoiding block-specific behaviours here, we should see if this is this more about preventing a block from being transformed into itself. In which case we could make this condition apply to any block type and not specifically the group block?

Originally posted by @aduth in #14908

@getdave getdave self-assigned this Jun 5, 2019
@getdave getdave added [Block] Group Affects the Group Block [Feature] Block API API that allows to express the block paradigm. labels Jun 5, 2019
@draganescu
Copy link
Contributor

What is this issue about, I am having trouble understanding it, even after visiting the original PR :)

@aduth
Copy link
Member

aduth commented Apr 23, 2020

The implementation has changed slightly since the issue was originally created, but I believe the goal is the same as it once was: A block should not be allowed to be transformed into its own block type.

This logic:

// Don't allow single Grouping blocks to be transformed into
// a Grouping block.
if (
! isMultiBlock &&
isContainerGroupBlock( sourceBlock.name ) &&
isContainerGroupBlock( transform.blockName )
) {
return false;
}

Can be simplified to one where the source block type and transform candidate block type are compared.

Something like:

// Don't allow a transform to the same block type.
if ( ! isMultiBlock && sourceBlock.name === transform.blockName ) {
	return false;
}

@jordesign
Copy link
Contributor

@getdave @aduth - just looping back through old issues, is this still relevant?

@getdave
Copy link
Contributor Author

getdave commented Aug 8, 2023

Seems very old. I think we can close it out.

@getdave getdave closed this as completed Aug 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Group Affects the Group Block [Feature] Block API API that allows to express the block paradigm.
Projects
None yet
Development

No branches or pull requests

4 participants