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

Handle cases when getBlockType returns undefined #41884

Merged

Conversation

mcliwanow
Copy link
Contributor

@mcliwanow mcliwanow commented Jun 22, 2022

What?

Added a few checks to determine if result of getBlockType is defined.

Why?

As reported in #34462 , getBlockType selector might return undefined and in few places it was assumed that it would return an object.

How?

In places that were assuming that result of getBlockType is an object I have added some checks to make sure that case when it's undefined is handled too.

I get no errors on the console but I see a "null" block after running wp.data.dispatch('core/blocks').removeBlockTypes('core/missing') and clicking on the block. Not sure if it's correct or not.

image

Testing Instructions

Test instructions can be found here.

Note
If someone could confirm that default values returned in those 2 places are correct it would be perfect 🙏

@mcliwanow mcliwanow requested a review from ellatrix as a code owner June 22, 2022 21:14
Copy link
Member

@jorgefilipecosta jorgefilipecosta left a comment

Choose a reason for hiding this comment

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

The changes look good to me 👍

@Mamaduka Mamaduka merged commit 02699f5 into WordPress:trunk Jun 29, 2022
@github-actions github-actions bot added this to the Gutenberg 13.7 milestone Jun 29, 2022
@bph bph added the [Package] Block editor /packages/block-editor label Jul 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Block editor /packages/block-editor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants