addAttribute() helper function overwrites blocktype attributes settings #15240
Labels
[Feature] Block API
API that allows to express the block paradigm.
[Feature] Extensibility
The ability to extend blocks or the editing experience
Good First Issue
An issue that's suitable for someone looking to contribute for the first time
Needs Dev
Ready for, and needs developer efforts
[Type] Bug
An existing feature does not function as intended
Describe the bug
When registering a block type that supports "anchor", the
attributes.anchor
setting is being overwritten by a helper function addAttribute().This helper function is designed to work with a static block type that returns an element from the
save()
function but is causing issues with dynamic block types that returnnull
.As an example, here is a dynamic block type that allows "anchor" and expects the anchor value to be serialized within the block HTML JSON.
Even though the anchor attribute has been defined for the block type, the result will actually look like this because the
attributes.anchor
setting has been overwritten by the addAttribute() helper function.Expected behavior
If the
attributes.anchor
setting has already been specified when registering a block type, it should not be overwritten by the helper function.Additional info
You can use the following line of code to remove the helper function, which allows dynamic block type to save "anchor" data, but obviously causes issues with core, and is not a valid solution:
The text was updated successfully, but these errors were encountered: