From cee85aacdb6e1744fc7f9766bd6c51bf944bd876 Mon Sep 17 00:00:00 2001 From: Nik Tsekouras Date: Mon, 19 Jun 2023 15:05:48 +0300 Subject: [PATCH] Fix template display in page details with a custom template (#51638) * Fix template display in page details with a custom template * address feedback --- .../page-details.js | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-page/page-details.js b/packages/edit-site/src/components/sidebar-navigation-screen-page/page-details.js index 996e1c93773144..290ae4907f9a9e 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-page/page-details.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-page/page-details.js @@ -95,15 +95,15 @@ function getPageDetails( page ) { export default function PageDetails( { id } ) { const { record } = useEntityRecord( 'postType', 'page', id ); - const { parentTitle, templateTitle } = useSelect( ( select ) => { - const { getEditedPostContext, getSettings } = unlock( - select( editSiteStore ) - ); - const defaultTemplateTypes = getSettings()?.defaultTemplateTypes; + const { getEditedPostContext } = unlock( select( editSiteStore ) ); const postContext = getEditedPostContext(); - + const templates = select( coreStore ).getEntityRecords( + 'postType', + 'wp_template', + { per_page: -1 } + ); // Template title. const templateSlug = // Checks that the post type matches the current theme's post type, otherwise @@ -112,10 +112,10 @@ export default function PageDetails( { id } ) { ? postContext?.templateSlug : null; const _templateTitle = - defaultTemplateTypes && templateSlug - ? defaultTemplateTypes.find( + templates && templateSlug + ? templates.find( ( template ) => template.slug === templateSlug - )?.title + )?.title?.rendered : null; // Parent page title. @@ -135,7 +135,7 @@ export default function PageDetails( { id } ) { templateTitle: _templateTitle, }; }, - [ record ] + [ record?.parent ] ); return (