Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Site Editor: Append template type and name to the site editor page title #47855

Merged
merged 3 commits into from
Feb 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion packages/edit-site/src/components/editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,20 @@ export default function Editor() {
);
const isReady = editedPostType !== undefined && editedPostId !== undefined;

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should remove "beta" now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I'm not entirely certain that we should concat translated items like that, we should probably be using sprintf here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's also a hook useEditedEntityRecord that would save a few lines of code here (allows to call getTitle directly and also provide access to the record if needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added a follow up PR here to cover off these suggestions.

) }`;
}

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

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