From e448fa70163ce936eae9aec454ca99f5a6287f15 Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Wed, 12 Jul 2023 15:07:32 +0400 Subject: [PATCH] Block Editor: Ensure synced patterns are accounted for in 'getAllowedBlocks' (#52546) --- packages/block-editor/src/store/selectors.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/block-editor/src/store/selectors.js b/packages/block-editor/src/store/selectors.js index 4cca99535a8e50..f7970843f8669d 100644 --- a/packages/block-editor/src/store/selectors.js +++ b/packages/block-editor/src/store/selectors.js @@ -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(), ] );