Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Announce title change
  • Loading branch information
kevin940726 committed Dec 6, 2021
commit 87c789b55c28ca4e9013cfc9eaab5606dbb027dd
4 changes: 3 additions & 1 deletion packages/edit-site/src/components/routes/use-title.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useEffect } from '@wordpress/element';
import { useSelect } from '@wordpress/data';
import { store as coreStore } from '@wordpress/core-data';
import { __, sprintf } from '@wordpress/i18n';
import { speak } from '@wordpress/a11y';

export default function useTitle( title ) {
const siteTitle = useSelect(
Expand All @@ -26,7 +27,8 @@ export default function useTitle( title ) {
if ( document.title !== formattedTitle ) {
document.title = formattedTitle;

// TODO: We might want to also add accessibility-related announcements here.
// Announce title on route change for screen readers.
speak( document.title );
}
}
}, [ title, siteTitle ] );
Expand Down