Skip to content

Commit

Permalink
Block Editor: Ensure synced patterns are accounted for in 'getAllowed…
Browse files Browse the repository at this point in the history
…Blocks'
  • Loading branch information
Mamaduka committed Jul 12, 2023
1 parent 56defb4 commit e0831a6
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/block-editor/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -2214,15 +2214,24 @@ export const getAllowedBlocks = createSelector(
return;
}

return getBlockTypes().filter( ( blockType ) =>
const blockTypes = getBlockTypes().filter( ( blockType ) =>
canIncludeBlockTypeInInserter( state, blockType, rootClientId )
);
const hasReusableBlock =
canInsertBlockTypeUnmemoized( state, 'core/block', rootClientId ) &&
getReusableBlocks( state ).length > 0;

return [
...blockTypes,
...( hasReusableBlock ? [ 'core/block' ] : [] ),
];
},
( state, rootClientId ) => [
state.blockListSettings[ rootClientId ],
state.blocks.byClientId,
state.settings.allowedBlockTypes,
state.settings.templateLock,
getReusableBlocks( state ),
getBlockTypes(),
]
);
Expand Down

0 comments on commit e0831a6

Please sign in to comment.