Description
I've got a custom block that has worked just fine in the post editor since ~2021. When I go to see the 7.0-beta1 Visual Revisions for a page that uses that block I get the dreaded "This block has encountered an error and cannot be previewed." message.
In my block's edit script, at one point I call
const parent = select( 'core/block-editor' ).getBlockParentsByBlockName( clientId, 'myblocks/my-parent-block-name' );
const { buttonOnly } = select( 'core/block-editor' ).getBlockAttributes( Array.isArray( parent ) ? parent[0] : parent );
That works fine in the editor (i.e., parent gets set to an array with the clientId of the parent block). But when I load the Visual Revision screen getBlockParentsByBlockName() returns an empty array, and thus the next call to getBlockAttributes() results in a run-time error.
A little bit of context in case it helps:
- this is an apiVersion: 1 block. Don't know if that part of the prob. Eventually, I'll need to fix that before 7.0 comes out, but I don't have time to do that right now...
Step-by-step reproduction instructions
n/a
Screenshots, screen recording, code snippet
No response
Environment info
- 7.0-beta1, custom hybrid theme
- Chrome 145.0.7632.110
- Win11 Pro for Workstations
Please confirm that you have searched existing issues in the repo.
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Please confirm which theme type you used for testing.
Description
I've got a custom block that has worked just fine in the post editor since ~2021. When I go to see the 7.0-beta1 Visual Revisions for a page that uses that block I get the dreaded "This block has encountered an error and cannot be previewed." message.
In my block's edit script, at one point I call
That works fine in the editor (i.e., parent gets set to an array with the
clientIdof the parent block). But when I load the Visual Revision screengetBlockParentsByBlockName()returns an empty array, and thus the next call togetBlockAttributes()results in a run-time error.A little bit of context in case it helps:
Step-by-step reproduction instructions
n/a
Screenshots, screen recording, code snippet
No response
Environment info
Please confirm that you have searched existing issues in the repo.
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Please confirm which theme type you used for testing.