Skip to content

Handle cases when getBlockType returns undefined#41884

Merged
Mamaduka merged 1 commit intoWordPress:trunkfrom
mcliwanow:update/check-if-block-type-is-set
Jun 29, 2022
Merged

Handle cases when getBlockType returns undefined#41884
Mamaduka merged 1 commit intoWordPress:trunkfrom
mcliwanow:update/check-if-block-type-is-set

Conversation

@mcliwanow
Copy link
Copy Markdown
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
Copy Markdown
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