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: Shorter screen reader announcement after changing pages #56339

Merged
merged 5 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
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
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 ] );
}
Loading