diff --git a/packages/block-editor/src/components/inserter/block-list.js b/packages/block-editor/src/components/inserter/block-list.js index b32c5dea57eace..6c794f21b01b34 100644 --- a/packages/block-editor/src/components/inserter/block-list.js +++ b/packages/block-editor/src/components/inserter/block-list.js @@ -118,14 +118,15 @@ export function InserterBlockList( { return (
{ hasChildItems && ( - + + + ) } { ! hasChildItems && !! suggestedItems.length && ! filterValue && ( diff --git a/packages/block-editor/src/components/inserter/child-blocks.js b/packages/block-editor/src/components/inserter/child-blocks.js index 362a56b79035a9..36e61006d4c608 100644 --- a/packages/block-editor/src/components/inserter/child-blocks.js +++ b/packages/block-editor/src/components/inserter/child-blocks.js @@ -1,16 +1,25 @@ /** * WordPress dependencies */ -import { withSelect } from '@wordpress/data'; -import { ifCondition, compose } from '@wordpress/compose'; +import { useSelect } from '@wordpress/data'; /** * Internal dependencies */ -import BlockTypesList from '../block-types-list'; import BlockIcon from '../block-icon'; -function ChildBlocks( { rootBlockIcon, rootBlockTitle, items, ...props } ) { +export default function ChildBlocks( { rootClientId, children } ) { + const { rootBlockTitle, rootBlockIcon } = useSelect( ( select ) => { + const { getBlockType } = select( 'core/blocks' ); + const { getBlockName } = select( 'core/block-editor' ); + const rootBlockName = getBlockName( rootClientId ); + const rootBlockType = getBlockType( rootBlockName ); + return { + rootBlockTitle: rootBlockType && rootBlockType.title, + rootBlockIcon: rootBlockType && rootBlockType.icon, + }; + } ); + return (
{ ( rootBlockIcon || rootBlockTitle ) && ( @@ -19,21 +28,7 @@ function ChildBlocks( { rootBlockIcon, rootBlockTitle, items, ...props } ) { { rootBlockTitle &&

{ rootBlockTitle }

}
) } - + { children }
); } - -export default compose( - ifCondition( ( { items } ) => items && items.length > 0 ), - withSelect( ( select, { rootClientId } ) => { - const { getBlockType } = select( 'core/blocks' ); - const { getBlockName } = select( 'core/block-editor' ); - const rootBlockName = getBlockName( rootClientId ); - const rootBlockType = getBlockType( rootBlockName ); - return { - rootBlockTitle: rootBlockType && rootBlockType.title, - rootBlockIcon: rootBlockType && rootBlockType.icon, - }; - } ) -)( ChildBlocks );