Skip to content

Commit

Permalink
Site editor: Shorter screen reader announcement after changing pages (#…
Browse files Browse the repository at this point in the history
…56339)

* Shorter title announcement.

* Reviewer feedback.

* Reviewer feedback.

* Improve translators comments.

---------

Co-authored-by: Andrea Fercia <[email protected]>
  • Loading branch information
alexstine and afercia authored Dec 4, 2023
1 parent 088223a commit 3d389c4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
4 changes: 2 additions & 2 deletions packages/edit-site/src/components/editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ export default function Editor( { listViewToggleElement, isLoading } ) {
let title;
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' ),
// translators: A breadcrumb trail for the Admin document title. %1$s: title of template being edited, %2$s: type of template (Template or Template Part).
__( '%1$s ‹ %2$s' ),
getTitle(),
POST_TYPE_LABELS[ editedPostType ] ??
POST_TYPE_LABELS[ TEMPLATE_POST_TYPE ]
Expand Down
13 changes: 3 additions & 10 deletions packages/edit-site/src/components/routes/use-title.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,16 @@ export default function useTitle( title ) {
if ( title && siteTitle ) {
// @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' ),
/* translators: Admin document title. 1: Admin screen name, 2: Network or site name. */
__( '%1$s ‹ %2$s ‹ Editor — WordPress' ),
decodeEntities( title ),
decodeEntities( siteTitle )
);

document.title = formattedTitle;

// Announce title on route change for screen readers.
speak(
sprintf(
/* translators: The page title that is currently displaying. */
__( 'Now displaying: %s' ),
document.title
),
'assertive'
);
speak( title, 'assertive' );
}
}, [ title, siteTitle, location ] );
}

0 comments on commit 3d389c4

Please sign in to comment.