File tree 1 file changed +13
-2
lines changed
packages/block-editor/src/store
1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -1628,8 +1628,18 @@ const isBlockVisibleInTheInserter = (
1628
1628
checkedBlocks . add ( blockName ) ;
1629
1629
1630
1630
// If parent blocks are not visible, child blocks should be hidden too.
1631
- if ( Array . isArray ( blockType ?. parent ) ) {
1632
- return blockType . parent . some (
1631
+ //
1632
+ // In some scenarios, blockType.parent may be a string.
1633
+ // A better approach would be sanitize parent in all the places that can be modified:
1634
+ // block registration, processBlockType, filters, etc.
1635
+ // In the meantime, this is a hotfix to prevent the editor from crashing.
1636
+ const parent =
1637
+ typeof blockType . parent === 'string' ||
1638
+ blockType . parent instanceof String
1639
+ ? [ blockType . parent ]
1640
+ : blockType . parent ;
1641
+ if ( Array . isArray ( parent ) ) {
1642
+ return parent . some (
1633
1643
( name ) =>
1634
1644
( blockName !== name &&
1635
1645
isBlockVisibleInTheInserter (
@@ -1643,6 +1653,7 @@ const isBlockVisibleInTheInserter = (
1643
1653
name === 'core/post-content'
1644
1654
) ;
1645
1655
}
1656
+
1646
1657
return true ;
1647
1658
} ;
1648
1659
You can’t perform that action at this time.
0 commit comments