-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Speak 'Block moved up/down' after using keyboard actions to move up/down #64966
Speak 'Block moved up/down' after using keyboard actions to move up/down #64966
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
Simply adding a message may convey incorrect information to the screen reader, because the message will always be read when the shortcut is executed.
For example, the following scenarios need to be considered:
- When a block is at the beginning of the content, it cannot be moved forward
- When a block is at the end of the content, it cannot be moved backward
- Multiple blocks may be selected
- There may be only one block in the content
- In a flex layout, blocks are moved left and right, not up and down
Also, I thinks the message Block moved {up|down}.
alone does not convey what changes have been made to the content. For example, a message like Move 2 blocks from position 3 right by one place
is needed.
I think we can use the getBlockMoverDescription()
function to cover all of these scenarios.
Thanks @t-hamano for the feedback. I'll be taking a look next week |
Thanks for the update! In my opinion, there is no need to make the processing an external variable. We can probably do it like this: export default function BlockTools( {
children,
__unstableContentRef,
...props
} ) {
// ...
function onKeyDown( event ) {
// ...
if (
isMatch( 'core/block-editor/move-up', event ) ||
isMatch( 'core/block-editor/move-down', event )
) {
const clientIds = getSelectedBlockClientIds();
if ( clientIds.length ) {
const direction = isMatch( 'core/block-editor/move-up', event )
? 'up'
: 'down';
event.preventDefault();
const rootClientId = getBlockRootClientId( clientIds[ 0 ] );
// Here's the logic
if ( direction === 'up' ) {
moveBlocksUp( clientIds, rootClientId );
} else {
moveBlocksDown( clientIds, rootClientId );
}
const description = getBlockMoverDescription(
// parameters
);
speak( description );
}
} else if ( isMatch( 'core/block-editor/duplicate', event ) ) {
// ...
}
}
// ...
} This will also allow us to standardize some of the duplicate processing between |
@t-hamano Good point much cleaner that way. I implemented the changes |
@n2erjo00 Thanks for the update! I'm sorry, I missed an important point. Perhaps we need to build a new logic for shortcuts or add a new argument like Also, I'm trying to check in this comment whether the current block mover reading itself is correct. Sorry for keeping you waiting, but I'd like to think of an ideal approach. |
Just noting a previous attempt to add audible messages was tried in #24894 more than 4 years ago. I'm not sure these messages should use We could consider to simplify the message but I think two different cases should be considered: Rationale:
I do realize distinguishin the two cases is more complex. If it turns out to be too comples, I'd have bo objections with a somehow noisy, redundant message for the buttons. |
Would the proper course of action to be to create similar function as |
https://github.com/WordPress/gutenberg/pull/24894/files was actually using a dedicated function to provide detailed confirmation messages. It was a little overkill maybe. @alexstine @talksina from your perspective, when a block is moved would you prefer a detailed confirmation message that announces the new position and direction, which may get a little noisy, or a shorter message? Examples:
|
The short message is probably okay considering even "1 step down" really doesn't communicate exactly where the block is. |
@t-hamano Added short confirmation message after block has been moved up|down |
@afercia @alexstine Thanks for the feedback! So let's use a short message here. @n2erjo00 I think two changes are needed to make the message more precise:
const message = sprintf(
// translators: %d: the name of the block that has been moved
_n(
'%d block moved.',
'%d blocks moved.',
clientIds.length
),
clientIds.length
);
speak( message ); The code is similar to here. |
@t-hamano Added period and logic for singular/plural |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! It seems to work as expected.
The video below shows how NVDA reads it out loud:
0640d4d865b75b3c736678a7b32e3e66.mp4
Note: I would like to close #24894, but add the people who worked on it as props.
|
…own (WordPress#64966) * Speak 'Block moved up/down' after using keyboard actions to move up/down * Created internal helper function to create description for speak function * Refactor away from helper function and simplify * Add short confirmation message after block has been moved up|down * End with period. Speak singular or plural * Speak the amount of moved blocks Co-authored-by: n2erjo00 <n2erjo00@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: afercia <afercia@git.wordpress.org> Co-authored-by: alexstine <alexstine@git.wordpress.org> Co-authored-by: ciampo <mciampini@git.wordpress.org> Co-authored-by: talksina <talksina@git.wordpress.org> Co-authored-by: enricobattocchi <lopo@git.wordpress.org> Co-authored-by: youknowriad <youknowriad@git.wordpress.org> Co-authored-by: mtias <matveb@git.wordpress.org>
What?
Describing to screen reader what just happened when user uses keyboard short cuts to move block up or down.
Why?
Closes #61168
Issue was reported by the linked issue.
How?
Using
speak
function to speak up after operation is done.Testing Instructions
⌘ + ⌥ + ⇧ + T or Y
CTRL + ALT + SHIFT + T or Y
Testing Instructions for Keyboard
Screenshots or screencast