Skip to content

Commit

Permalink
Reviewer feedback.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexstine committed Nov 22, 2023
1 parent ce35d59 commit 291a953
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
10 changes: 1 addition & 9 deletions packages/edit-site/src/components/editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,16 +168,8 @@ export default function Editor( { listViewToggleElement, isLoading } ) {
const postWithTemplate = context?.postId;

let title;
let accessibleTitle;
if ( hasLoadedPost ) {
title = sprintf(
// translators: A breadcrumb trail in browser tab. %1$s: title of template being edited, %2$s: type of template (Template or Template Part).
__( '%1$s ‹ %2$s ‹ Editor' ),
getTitle(),
POST_TYPE_LABELS[ editedPostType ] ??
POST_TYPE_LABELS[ TEMPLATE_POST_TYPE ]
);
accessibleTitle = sprintf(
// translators: A breadcrumb trail in browser tab. %1$s: title of template being edited, %2$s: type of template (Template or Template Part).
__( '%1$s ‹ %2$s' ),
getTitle(),
Expand All @@ -188,7 +180,7 @@ export default function Editor( { listViewToggleElement, isLoading } ) {

// Only announce the title once the editor is ready to prevent "Replace"
// action in <URLQueryController> from double-announcing.
useTitle( hasLoadedPost && title, accessibleTitle );
useTitle( hasLoadedPost && title );

const loadingProgressId = useInstanceId(
CanvasLoader,
Expand Down
2 changes: 1 addition & 1 deletion packages/edit-site/src/components/list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default function List() {
[ templateType ]
);

useTitle( postType, postType );
useTitle( postType?.labels?.name );

// `postType` could load in asynchronously. Only provide the detailed region labels if
// the postType has loaded, otherwise `InterfaceSkeleton` will fallback to the defaults.
Expand Down
8 changes: 4 additions & 4 deletions packages/edit-site/src/components/routes/use-title.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { unlock } from '../../lock-unlock';

const { useLocation } = unlock( routerPrivateApis );

export default function useTitle( title, accessibleTitle ) {
export default function useTitle( title ) {
const location = useLocation();
const siteTitle = useSelect(
( select ) =>
Expand All @@ -39,15 +39,15 @@ export default function useTitle( title, accessibleTitle ) {
// @see https://github.com/WordPress/wordpress-develop/blob/94849898192d271d533e09756007e176feb80697/src/wp-admin/admin-header.php#L67-L68
const formattedTitle = sprintf(
/* translators: Admin screen title. 1: Admin screen name, 2: Network or site name. */
__( '%1$s ‹ %2$s — WordPress' ),
__( '%1$s ‹ %2$s ‹ Editor — WordPress' ),
decodeEntities( title ),
decodeEntities( siteTitle )
);

document.title = formattedTitle;

// Announce title on route change for screen readers.
speak( accessibleTitle || formattedTitle, 'assertive' );
speak( title, 'assertive' );
}
}, [ title, accessibleTitle, siteTitle, location ] );
}, [ title, siteTitle, location ] );
}

0 comments on commit 291a953

Please sign in to comment.