-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix console errors when an Inner Block is deleted, and when using lightBlockWrapper #33572
Conversation
Size Change: +3 B (0%) Total Size: 1.04 MB
ℹ️ View Unchanged
|
It looks like it's a deeper issue related to block re-rendering. Somehow, the block wrapper is trying to access a block object that is no longer present in the post. We should investigate it further because there might be more issues related to that. Ideally, we should bail out from re-rendering as early as possible when the block is no longer present in the post. @youknowriad, might it be related to async block updates mechanic? |
#32088 tried to resolve this, but apparently not entirely? |
I missed this PR and I applied some of the changes myself 😅 It looks like there are some of the changes that we still want to land. There is now even a tracking issue for similar issues in the codebase: #34462. @mikejolley, would you mind rebasing this PR? I'd like to test it and land next week. |
0cd05c7
to
631f23a
Compare
@gziolo after rebasing it looks like your changes supercede this so Ill just close it. |
Description
I am using some Inner Blocks that use apiVersion 2 and the light block wrapper. When one of these inner blocks are deleted, the console fills with errors:
This is because some API methods such as
getBlockName
,getBlockType
, andgetBlockAttributes
return null or undefined once a block has been removed. My fix is to check that a value is returned first within the affected hooks. cc @nerradDiscovered in woocommerce/woocommerce-blocks#4479
Steps to Reproduce
Edit: I found a way to reproduce this with only Gutenberg blocks.
How has this been tested?
Tested before and after patch and ensured the errors were not logged to the console and there was no regression in inner block functionality. Running locally using WP Local environment. The blocks affected by this bug are part of woocommerce-gutenberg-products-block.
Types of changes
Bug fix - Checking variables exist.
Checklist:
*.native.js
files for terms that need renaming or removal).