diff --git a/packages/edit-site/src/components/sidebar-edit-mode/template-panel/template-areas.js b/packages/edit-site/src/components/sidebar-edit-mode/template-panel/template-areas.js
index fd00d9d2c0e24d..24dcd301bf2399 100644
--- a/packages/edit-site/src/components/sidebar-edit-mode/template-panel/template-areas.js
+++ b/packages/edit-site/src/components/sidebar-edit-mode/template-panel/template-areas.js
@@ -73,7 +73,7 @@ export default function TemplateAreas() {
{ templateParts.map( ( { templatePart, block } ) => (
- -
+
-
{
- const { getEntityRecord } = select( coreStore );
- const siteSettings = getEntityRecord( 'root', 'site' );
- const { getSettings } = unlock( select( editSiteStore ) );
- const _currentTemplateParts =
- select( editSiteStore ).getCurrentTemplateTemplateParts();
- const siteEditorSettings = getSettings();
- const _postsPageRecord = siteSettings?.page_for_posts
- ? select( coreStore ).getEntityRecord(
- 'postType',
- 'page',
- siteSettings?.page_for_posts
- )
- : EMPTY_OBJECT;
+ } = useSelect( ( select ) => {
+ const { getEntityRecord } = select( coreStore );
+ const { getSettings, getCurrentTemplateTemplateParts } = unlock(
+ select( editSiteStore )
+ );
+ const siteSettings = getEntityRecord( 'root', 'site' );
+ const _postsPageRecord = siteSettings?.page_for_posts
+ ? getEntityRecord(
+ 'postType',
+ 'page',
+ siteSettings?.page_for_posts
+ )
+ : EMPTY_OBJECT;
- return {
- allowCommentsOnNewPosts:
- siteSettings?.default_comment_status === 'open',
- postsPageTitle: _postsPageRecord?.title?.rendered,
- postsPageId: _postsPageRecord?.id,
- postsPerPage: siteSettings?.posts_per_page,
- templatePartAreas: siteEditorSettings?.defaultTemplatePartAreas,
- currentTemplateParts: _currentTemplateParts,
- };
- },
- [ postType, postId ]
- );
+ return {
+ allowCommentsOnNewPosts:
+ siteSettings?.default_comment_status === 'open',
+ postsPageTitle: _postsPageRecord?.title?.rendered,
+ postsPageId: _postsPageRecord?.id,
+ postsPerPage: siteSettings?.posts_per_page,
+ templatePartAreas: getSettings()?.defaultTemplatePartAreas,
+ currentTemplateParts: getCurrentTemplateTemplateParts(),
+ };
+ }, [] );
const [ commentsOnNewPostsValue, setCommentsOnNewPostsValue ] =
useState( '' );
@@ -126,11 +117,12 @@ export default function HomeTemplateDetails() {
*/
const templateAreas = useMemo( () => {
return currentTemplateParts.length && templatePartAreas
- ? currentTemplateParts.map( ( { templatePart } ) => ( {
+ ? currentTemplateParts.map( ( { templatePart, block } ) => ( {
...templatePartAreas?.find(
( { area } ) => area === templatePart?.area
),
...templatePart,
+ clientId: block.clientId,
} ) )
: [];
}, [ currentTemplateParts, templatePartAreas ] );
@@ -214,9 +206,9 @@ export default function HomeTemplateDetails() {
>
{ templateAreas.map(
- ( { label, icon, theme, slug, title } ) => (
+ ( { clientId, label, icon, theme, slug, title } ) => (