From 7b6e775e6b557d176e81b0597c4feca665d6dcf4 Mon Sep 17 00:00:00 2001 From: Dhananjay Kuber Date: Wed, 15 Jan 2025 09:22:43 +0530 Subject: [PATCH] Fix: Site Editor Template part is missing an icon in the sidebar (#68653) Co-authored-by: dhananjaykuber Co-authored-by: Mamaduka Co-authored-by: im3dabasia --- .../editor/src/store/private-selectors.js | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/packages/editor/src/store/private-selectors.js b/packages/editor/src/store/private-selectors.js index 56fa6728371489..73bf19f3d99937 100644 --- a/packages/editor/src/store/private-selectors.js +++ b/packages/editor/src/store/private-selectors.js @@ -26,6 +26,7 @@ import { getEntityFields as _getEntityFields, isEntityReady as _isEntityReady, } from '../dataviews/store/private-selectors'; +import { getTemplatePartIcon } from '../utils'; const EMPTY_INSERTION_POINT = { rootClientId: undefined, @@ -97,15 +98,21 @@ export const getPostIcon = createRegistrySelector( postType === 'wp_template_part' || postType === 'wp_template' ) { - return ( - ( - select( coreStore ).getEntityRecord( - 'root', - '__unstableBase' - )?.default_template_part_areas || [] - ).find( ( item ) => options.area === item.area )?.icon || - layout + const templateAreas = + select( coreStore ).getEntityRecord( + 'root', + '__unstableBase' + )?.default_template_part_areas || []; + + const areaData = templateAreas.find( + ( item ) => options.area === item.area ); + + if ( areaData?.icon ) { + return getTemplatePartIcon( areaData.icon ); + } + + return layout; } if ( CARD_ICONS[ postType ] ) { return CARD_ICONS[ postType ];