Skip to content
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
1 change: 1 addition & 0 deletions packages/editor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- Header: Allow the Back button column to grow when "Show button text labels" is enabled so the label is not obscured by the following controls ([#81701](https://github.com/WordPress/gutenberg/pull/81701)).
- Notes: Stop forcing capitalization of the user name in a note byline, so the name is shown as the user set it ([#81788](https://github.com/WordPress/gutenberg/pull/81788)).
- Device Preview: Center the editor canvas with the canvas container's own flex alignment rather than the canvas's auto margins, which were conditional on the resize handles being active. Switching from the mobile or tablet preview back to desktop no longer expands the canvas from the left edge ([#81484](https://github.com/WordPress/gutenberg/pull/81484)).
- `PostSchedule`: Announce the new publish date to screen readers when the date is changed ([#81629](https://github.com/WordPress/gutenberg/pull/81629)).

### Internal

Expand Down
18 changes: 16 additions & 2 deletions packages/editor/src/components/post-schedule/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { parseISO, endOfMonth, startOfMonth } from 'date-fns';
import { speak } from '@wordpress/a11y';
import { getSettings } from '@wordpress/date';
import { _x } from '@wordpress/i18n';
import { __, _x, sprintf } from '@wordpress/i18n';
import { useDispatch, useSelect } from '@wordpress/data';
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
import { useState, useMemo } from '@wordpress/element';
import { store as coreStore } from '@wordpress/core-data';
import { store as editorStore } from '../../store';
import { getFullPostScheduleLabel } from './label';
import { unlock } from '../../lock-unlock';

const { PrivatePublishDateTimePicker } = unlock( blockEditorPrivateApis );
Expand Down Expand Up @@ -42,7 +44,19 @@ export function PrivatePostSchedule( {
);

const { editPost } = useDispatch( editorStore );
const onUpdateDate = ( date ) => editPost( { date } );
const onUpdateDate = ( date ) => {
editPost( { date } );
speak(
date
? sprintf(
// translators: %s: The new publish date and time, e.g. "June 3, 2025 12:00 pm UTC+0".
__( 'Publish date set to %s.' ),
getFullPostScheduleLabel( date )
)
: __( 'Publish date set to now.' ),
'assertive'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What is the reason for using "assertive" instead of the default "polite"?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think direct actions are announced with "assertive" - "block inserter", "link removed", etc. Those all use assertive.

It would be nice to have a brief guideline on which politeness level to use in each case. Recently, I swapped "assertive" for "polite" to announce category filtering results (#81422), which seems to be the pattern in the project, but now I see more places using "assertive".

@joedolson, is this something we can document in guidelines?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should definitely try and identify guidelines. It's all about immediacy: a polite announcement will be deferred until after other speaking has completed, and an assertive announcement will be announced immediately, interrupting other announcements. The complicating factor is that the length of other ongoing announcements is going to be a mitigating factor. For example, if the active element has a lengthy aria-describedby target, and a polite announcement, that announcement will be quite a while later - and may never be announced, if the user interrupts speaking before it happens.

I'll chat with the rest of the team and try and set some guidelines that we can attempt to apply generally, so that we have some consistency.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you, @joedolson!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hi all, thank you for the discussion.
"Assertive" was chosen because this is a confirmation of a direct user action, which seems to be the existing pattern in the project, as @Mamaduka noted e.g., "Link removed." / "Link inserted." in the link UI, "%s applied." / "%s removed." when toggling formats, and the added/removed messages in FormTokenField. "Polite" seems to be reserved for background or asynchronous updates, e.g., "Media upload started" / "Media upload complete", or result counts after filtering.
I think we can go with assertive but I am happy to change after if it does not matches the guidelines.

);
};

const [ previewedMonth, setPreviewedMonth ] = useState(
startOfMonth( new Date( postDate ) )
Expand Down
Loading