Deprecation does not work if Block Wrapper does not use blockProps #61833
Labels
[Feature] Block API
API that allows to express the block paradigm.
[Feature] Block Validation/Deprecation
Handling block validation to determine accuracy and deprecation
[Type] Bug
An existing feature does not function as intended
Description
I have created a repo to illustrate the issue.
https://github.com/digamber89/block-deprecation-issue
I am experiencing an issue in WordPress Gutenberg with block deprecation not functioning as intended
For deprecation save output an automatic class
wp-block-blockNamesSpace-blockName
is appended to the output generated by the save function of the installed block. This addition, while not inherently problematic, is causing difficulties when it comes to block deprecation.The dilemma arises when a block's save function does not have the automatically added class.
During validation, when checking against deprecation/old block the class is auto inserted which creates a discrepancy between the original saved content and the newly generated content.
For example i will use version 1.0.0 to version 1.1.0 to illustrate in the below example.
Save.js - version 1.0.0
Lets say we change the block for next update:
Save.js - version 1.1.0 ( change p to div )
Handling deprecation via index.js - version 1.1.0
This deprecation will not work. Because the block created for the deprecations is auto adding the
wp-block-blockNamesSpace-blockName
class to the output for the save functions causing the block comparison to return as in correct so the save content isSaved Content
<p>Test Block Deprecation Issue – hello from the saved content!</p>
But
Save Function Output For Deprecation being compared is
<div className="wp-block-blockNamesSpace-blockName">Test Block Deprecation Issue – hello from the saved content!</div>
To check this I modified
packages/blocks/src/api/validation/index.js
packages/blocks/src/api/parser/apply-block-deprecated-versions.js
To validate that this is the exact issue that's happening.
Step-by-step reproduction instructions
Expected result Deprecation will work.
But you will still see Attempt block recovery.
Screenshots, screen recording, code snippet
https://go.screenpal.com/watch/cZhrqhVLAoA
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
The text was updated successfully, but these errors were encountered: