Skip to content

Commit 91c2aad

Browse files
committed
Cast string values to arrays
1 parent 4c8d4cc commit 91c2aad

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

packages/block-editor/src/store/selectors.js

+13-2
Original file line numberDiff line numberDiff line change
@@ -1628,8 +1628,18 @@ const isBlockVisibleInTheInserter = (
16281628
checkedBlocks.add( blockName );
16291629

16301630
// 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(
16331643
( name ) =>
16341644
( blockName !== name &&
16351645
isBlockVisibleInTheInserter(
@@ -1643,6 +1653,7 @@ const isBlockVisibleInTheInserter = (
16431653
name === 'core/post-content'
16441654
);
16451655
}
1656+
16461657
return true;
16471658
};
16481659

0 commit comments

Comments
 (0)