diff --git a/editor/store/selectors.js b/editor/store/selectors.js index 3f16a0b80fc20..43acdf5553162 100644 --- a/editor/store/selectors.js +++ b/editor/store/selectors.js @@ -1120,6 +1120,11 @@ function buildInserterItemFromReusableBlock( enabledBlockTypes, reusableBlock ) return null; } + const referencedBlockType = getBlockType( reusableBlock.type ); + if ( ! referencedBlockType ) { + return null; + } + return { // Attributes used for insertion name: 'core/block', @@ -1127,7 +1132,7 @@ function buildInserterItemFromReusableBlock( enabledBlockTypes, reusableBlock ) // Attributes shown in the inserter title: reusableBlock.title, - icon: 'layout', + icon: referencedBlockType.icon, category: 'reusable-blocks', // Metadata diff --git a/editor/store/test/selectors.js b/editor/store/test/selectors.js index 067c9d237883c..17231c09bec2d 100644 --- a/editor/store/test/selectors.js +++ b/editor/store/test/selectors.js @@ -98,6 +98,7 @@ describe( 'selectors', () => { save: ( props ) => props.attributes.text, category: 'common', title: 'test block', + icon: 'test', keywords: [ 'testing' ], useOnce: true, } ); @@ -2258,7 +2259,7 @@ describe( 'selectors', () => { name: 'core/test-block', initialAttributes: {}, title: 'test block', - icon: 'block-default', + icon: 'test', category: 'common', keywords: [ 'testing' ], isDisabled: false, @@ -2295,7 +2296,11 @@ describe( 'selectors', () => { }, reusableBlocks: { data: { - 123: { id: 123, title: 'My reusable block' }, + 123: { + id: 123, + title: 'My reusable block', + type: 'core/test-block', + }, }, }, }; @@ -2305,7 +2310,7 @@ describe( 'selectors', () => { name: 'core/block', initialAttributes: { ref: 123 }, title: 'My reusable block', - icon: 'layout', + icon: 'test', category: 'reusable-blocks', keywords: [], isDisabled: false, @@ -2337,7 +2342,7 @@ describe( 'selectors', () => { }, reusableBlocks: { data: { - 123: { id: 123 }, + 123: { id: 123, type: 'core/test-block' }, }, }, }; @@ -2391,7 +2396,7 @@ describe( 'selectors', () => { }, reusableBlocks: { data: { - 123: { id: 123 }, + 123: { id: 123, type: 'core/test-block' }, }, }, };