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

Add a way to modify what happens when you duplicate a block #35755

Open
fabiankaegy opened this issue Oct 19, 2021 · 1 comment
Open

Add a way to modify what happens when you duplicate a block #35755

fabiankaegy opened this issue Oct 19, 2021 · 1 comment
Assignees
Labels
[Feature] Block API API that allows to express the block paradigm. [Type] Enhancement A suggestion for improvement.

Comments

@fabiankaegy
Copy link
Member

What problem does this address?

When you duplicate a block it copies over 1to1 all the attributes and nested blocks. Which is exactly what it should do in 99% of cases. But when you for example duplicate a block that has a custom anchor set for your block that now causes an issue since the id attribute no longer is unique and you have multiple elements on the page that share the same ID.
This is a problem every time you need to store a unique identified in a block.

What is your proposed solution?

Like the migration callback function you can define for block depreciation it would be cool to add something similar to block duplication that allows you to override the behavior of core.

Alternatively, a hook that fires inside the cloning process would also solve the problem and would also work for things like the core anchor support.

@fabiankaegy fabiankaegy added the [Type] Enhancement A suggestion for improvement. label Oct 19, 2021
@fabiankaegy fabiankaegy changed the title Add ability to define a duplicationHandler to a block Add a way to modify what happens when you duplicate a block Oct 19, 2021
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Oct 19, 2021
@gziolo gziolo added the [Feature] Block API API that allows to express the block paradigm. label Nov 2, 2021
@gziolo
Copy link
Member

gziolo commented Nov 2, 2021

As noted in #35757 (comment), we might want to take a different approach and provide options for block attributes to customize the behavior inside the framework when certain actions happen like duplication in this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block API API that allows to express the block paradigm. [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants