Skip to content
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

InnerBlocks: Make sure blockType is set before trying to use it #63351

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@ function UncontrolledInnerBlocks( props ) {
/>
);

if ( Object.keys( blockType.providesContext ).length === 0 ) {
if (
! blockType?.providesContext ||
Object.keys( blockType.providesContext ).length === 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still not fully understanding how it's possible to have inner blocks without a block type. Could you give an example?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, I am not sure how this is happening either! But, it happens in the scenario mentioned in the description with WooCommerce's use of blocks in the new product editor. Ultimately, the root problem may lie somewhere in WooCommerce's handling of blocks, but this change seems like a reasonable defensive change in GB.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'm still curious. This is a legitimate error tbh, but sure, let's gracefully fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. We will still be attempting to address the root cause of this! I'm very curious too.

) {
return items;
}

Expand Down
Loading