Skip to content

Commit

Permalink
Fix template/template-part titles and icons
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Dec 5, 2023
1 parent 593b841 commit 4f69987
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions packages/editor/src/components/document-bar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,22 @@ function BaseDocumentActions( { postType, postId, onBack } ) {
postType,
postId
);
const { templateIcon, templateTitle } = useSelect( ( select ) => {
const { __experimentalGetTemplateInfo: getTemplateInfo } =
select( editorStore );
const templateInfo = getTemplateInfo( document );
return {
templateIcon: templateInfo.icon,
templateTitle: templateInfo.title,
};
} );
const isNotFound = ! document && ! isResolving;
const icon = icons[ postType ] ?? pageIcon;
const [ isAnimated, setIsAnimated ] = useState( false );
const isMounting = useRef( true );
const isTemplate = [ 'wp_template', 'wp_template_part' ].includes(
postType
);

useEffect( () => {
if ( ! isMounting.current ) {
Expand Down Expand Up @@ -134,14 +146,14 @@ function BaseDocumentActions( { postType, postId, onBack } ) {
spacing={ 1 }
justify="center"
>
<BlockIcon icon={ icon } />
<BlockIcon icon={ isTemplate ? templateIcon : icon } />
<Text size="body" as="h1">
{ typeLabels[ postType ] && (
<VisuallyHidden as="span">
{ typeLabels[ postType ] }
</VisuallyHidden>
) }
{ document.title }
{ isTemplate ? templateTitle : document.title }
</Text>
</HStack>
<span className="edit-site-document-actions__shortcut">
Expand Down

0 comments on commit 4f69987

Please sign in to comment.