Open fabiankaegy opened 2 years ago
As noted in https://github.com/WordPress/gutenberg/pull/35757#issuecomment-957568383, 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.
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.