Skip to content

Commit

Permalink
Fix template display in page details with a custom template (#51638)
Browse files Browse the repository at this point in the history
* Fix template display in page details with a custom template

* address feedback
  • Loading branch information
ntsekouras authored Jun 19, 2023
1 parent a40838d commit cee85aa
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -135,7 +135,7 @@ export default function PageDetails( { id } ) {
templateTitle: _templateTitle,
};
},
[ record ]
[ record?.parent ]
);
return (
<VStack spacing={ 5 }>
Expand Down

0 comments on commit cee85aa

Please sign in to comment.