Skip to content

Commit

Permalink
Use template part area label rather than template part title
Browse files Browse the repository at this point in the history
  • Loading branch information
ockham committed Oct 28, 2021
1 parent 88adb53 commit 4ef8ac1
Showing 1 changed file with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ export default function EntityRecordItem( {
// Handle templates that might use default descriptive titles
const entityRecordTitle = useSelect(
( select ) => {
if ( 'postType' !== kind || 'wp_template' !== name ) {
if (
'postType' !== kind ||
! [ 'wp_template', 'wp_template_part' ].includes( name )
) {
return title;
}

Expand All @@ -47,9 +50,25 @@ export default function EntityRecordItem( {
name,
key
);
return select( editorStore ).__experimentalGetTemplateInfo(
template
).title;

if ( name === 'wp_template' ) {
return select( editorStore ).__experimentalGetTemplateInfo(
template
).title;
}

if ( name === 'wp_template_part' ) {
const templatePartAreas = select(
editorStore
).__experimentalGetDefaultTemplatePartAreas();

return (
templatePartAreas.find(
( templatePartArea ) =>
templatePartArea.area === template.area
)?.label ?? title
);
}
},
[ name, kind, title, key ]
);
Expand Down

0 comments on commit 4ef8ac1

Please sign in to comment.