-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Block sequential deprecations result in attribute data loss #59694
Copy link
Copy link
Closed
Labels
Needs TestingNeeds further testing to be confirmed.Needs further testing to be confirmed.[Feature] BlocksOverall functionality of blocksOverall functionality of blocks[Status] StaleGives the original author opportunity to update before closing. Can be reopened as needed.Gives the original author opportunity to update before closing. Can be reopened as needed.[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intended
Metadata
Metadata
Assignees
Labels
Needs TestingNeeds further testing to be confirmed.Needs further testing to be confirmed.[Feature] BlocksOverall functionality of blocksOverall functionality of blocks[Status] StaleGives the original author opportunity to update before closing. Can be reopened as needed.Gives the original author opportunity to update before closing. Can be reopened as needed.[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intended
Type
Fields
Give feedbackNo fields configured for issues without a type.
Description
I'm having trouble with block deprecations being run sequentially on a dynamic block.
I have created the following example: a block with two initial attributes (name and surname), which get renamed one after the other (to firstName and lastName, respectively) in two separate deprecation functions. What happens is that the second one being run, overrides the outcome of the first, resulting in the first updated attribute being lost.
In our case, being the surname the first one being run in the
deprecated.jsexported array, only the name -> firstName attribute is correctly kept.Here's a link to the repo where the issue is happening: https://github.com/andreg/BlockDeprecations
Specifically, here's a link to the
deprecated.jsfile: https://github.com/andreg/BlockDeprecations/blob/main/src/deprecated.jsStep-by-step reproduction instructions
<!-- wp:test/test {"name":"John", "surname": "Doe"} /-->wp.data.select( 'core/block-editor' ).getBlocks()[0].attributesYou'll see thatthe firstName attribute is present and with the correct value, while the lastName attribute is missing, infact it's still present the previous surname attribute.
Screenshots, screen recording, code snippet
No response
Environment info
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes