Skip to content

Commit

Permalink
Simplify the title construction
Browse files Browse the repository at this point in the history
  • Loading branch information
glendaviesnz committed Feb 8, 2023
1 parent d51f656 commit 9426e5e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/edit-site/src/components/editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,18 +138,20 @@ export default function Editor() {
);
const isReady = editedPostType !== undefined && editedPostId !== undefined;

let titleBreadcrumb;
let title;
if ( isReady && editedPost ) {
const type =
editedPostType === 'wp_template'
? __( 'Template' )
: __( 'Template Part' );
titleBreadcrumb = `${ editedPost.title?.rendered }${ type } ‹ `;
title = `${ editedPost.title?.rendered }${ type }${ __(
'Editor (beta)'
) }`;
}

// Only announce the title once the editor is ready to prevent "Replace"
// action in <URlQueryController> from double-announcing.
useTitle( isReady && `${ titleBreadcrumb }${ __( 'Editor (beta)' ) }` );
useTitle( isReady && title );

if ( ! isReady ) {
return <CanvasSpinner />;
Expand Down

0 comments on commit 9426e5e

Please sign in to comment.