From 1520739f1bb8125a40908d556cf79de8e1fc2219 Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Tue, 1 Aug 2023 14:06:40 +0200 Subject: [PATCH] Simplify --- .../src/hooks/auto-inserting-blocks.js | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/packages/block-editor/src/hooks/auto-inserting-blocks.js b/packages/block-editor/src/hooks/auto-inserting-blocks.js index b37dd79f20edc..bc3e55feb8c25 100644 --- a/packages/block-editor/src/hooks/auto-inserting-blocks.js +++ b/packages/block-editor/src/hooks/auto-inserting-blocks.js @@ -19,21 +19,10 @@ function AutoInsertingBlocksControl( props ) { return getBlockTypes(); }, [] ); - const autoInsertedBlocksForCurrentBlock = blocks.reduce( - ( autoInsertedBlocks, block ) => { - if ( ! block.autoInsert ) { - return autoInsertedBlocks; - } - - const name = Object.keys( block.autoInsert ).find( - ( n ) => n === props.blockName - ); - if ( name !== undefined ) { - autoInsertedBlocks.push( block ); - } - return autoInsertedBlocks; - }, - [] + const autoInsertedBlocksForCurrentBlock = blocks.filter( + ( block ) => + block.autoInsert && + Object.keys( block.autoInsert ).includes( props.blockName ) ); return (