createUpgradedEmbedBlock breaks when block type is unregistered #15883
Labels
[Block] Embed
Affects the Embed Block
[Block] Video
Affects the Video Block
[Feature] Block Transforms
Block transforms from one block to another
[Type] Bug
An existing feature does not function as intended
Describe the bug
When creating a Video block and pasting a YouTube URL in the "Insert from URL" field, the editor automatically creates a YouTube block for it.
Here's where this happens:
gutenberg/packages/block-library/src/video/edit.js
Lines 95 to 114 in ee7c19a
And here's the function in question:
gutenberg/packages/block-library/src/embed/util.js
Lines 61 to 118 in ee7c19a
Now, in our environment we unregistered all embed blocks, but kept the video block.
Since neither
createUpgradedEmbedBlock
norcreateBlock
verify whether the block type exists, this results in errors becauseblockType
is not an object here, and thus it cannot accessblockType.attributes
:gutenberg/packages/blocks/src/api/factory.js
Lines 40 to 45 in 03f04f3
Suggested fix
createBlock
could be considered being a bit too low level for adding a check here, so I think adding aif ( ! getBlockType( matchingBlock ) ) { return; }
check tocreateUpgradedEmbedBlock
would be the appropriate solution.To reproduce
Steps to reproduce the behavior:
Expected behavior
No upgrade is attempted / no error happens.
Screenshots
Desktop:
The text was updated successfully, but these errors were encountered: