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

Add audible messages to confirm the "move block" actions #24894

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

enricobattocchi
Copy link

Fixes #23995.

Description

Added audible messages to aria-live="assertive" region to confirm the "move" action to the screen reader users.
The messages check for orientation and RTL to make sure they are consistent with the label of the button used to perform the action.

This PR has been created during the Yoast Contributor Day.
The people who worked on it are @jcomack, @afercia, @enricobattocchi.

How has this been tested?

  1. edit a (new) post with a screen reader active
  2. add a number of blocks, plus a button list (which has a horizontal orientation)
  3. move the blocks using the buttons or the keyboard shortcuts and check that the actions are confirmed by the audible messages. Notice that button can be moved left or right and the messages change accordingly.
  4. Try also to select multiple blocks and move them together to hear a message telling the correct number of blocks moved.
  5. Switch to a RTL environment and see that the "move up" action becomes "move right" for the buttons, and the audible messages are correct.
  6. You can also the content of the <div id="a11y-speak-assertive"> to read the messages without a screen reader active.

Types of changes

New feature (non-breaking change which adds functionality)

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR.

@ZebulanStanphill ZebulanStanphill added the [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). label Aug 28, 2020
@afercia
Copy link
Contributor

afercia commented Aug 29, 2020

To fully test, worth reminding the keyboard shortcuts to move blocks are (on macOS):

  • Shift Control Option Y: move down (or right for LTR)
  • Shift Control Option T: move up (or left for LTR)

Moving left or right can be tested on the "Buttons" or "Social icons" blocks:

Screenshot 2020-08-29 at 16 27 33

Screenshot illustrating moving three social icons buttons when using Safari and VoiceOver:

Screenshot 2020-08-29 at 16 27 07


announceBlockMoved( state, direction );
},
MOVE_BLOCKS_UP: ( action, { getState } ) => {
Copy link
Member

@mtias mtias Aug 29, 2020

Choose a reason for hiding this comment

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

It's odd to read an action type of "UP" while orientation changes it to right / left within. It'd be better to have a single "MOVE_BLOCKS" type and handle all cardinals within. (Alternatively, there could be four action types.)

Copy link
Contributor

Choose a reason for hiding this comment

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

This just uses the existing actions. Actually, there are no specific actions for "left" and "right". Not opposed to improvements but the current actions implementation is out of the scope of this issue.

let direction = 'down';

if ( action.orientation === 'horizontal' ) {
direction = settings.isRTL ? 'left' : 'right';
Copy link
Member

Choose a reason for hiding this comment

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

Is this correct? Wouldn't the actual move actions still be accurate given left moves to the left regardless of RTL?

Copy link
Contributor

Choose a reason for hiding this comment

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

It is correct. "down" moves the block to the "following" position, whether it's vertical or horizontal. In LTR, the "following" horizontal position is right, while in RTL is left.

const blockCount = getSelectedBlockCount( state );
let message;

switch ( direction ) {
Copy link
Member

Choose a reason for hiding this comment

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

It seems all these could be inlined and don't need the extra abstraction of announceBlockMoved

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd disagree. Seems to me it's way more readable this way.

@talldan talldan added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Sep 2, 2020
@afercia
Copy link
Contributor

afercia commented Sep 8, 2020

I tested again this PR, also on Windows Firefox + NVDA and in RTL. Everything works as expected. Code looks good as is, to me. Kindly asking to have a new review please, when there's a chance 🙂 /Cc @youknowriad @talldan

In RTL: last action was "move to right":

Screenshot (127)

@@ -219,6 +271,30 @@ export default {
)
);
},
MOVE_BLOCKS_DOWN: ( action, { getState } ) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we move away from effects and instead implement these action creator as "generators"? see moveBlocksToPosition as an example of action generator.

Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure I follow. Maybe I lack context or it's a terminology thing 🙂 In this PR we just reused actions that already exist. Are you suggesting a major refactoring in the way these actions are created?

Copy link
Contributor

Choose a reason for hiding this comment

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

We're slowly moving away from using "effects" (see effects.js file and the https://github.com/aduth/refx middleware) and instead we're trying to replace them with "generator" actions (consistency with resolvers).

These are just two technologies that allow the same thing: writing complex actions with side effects.
So ideally, new code shouldn't add new effects and use generators instead.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good to know. Is this documented anywhere? How new contributors are supposed to be informed about this? 🙂 If it's not documented, I'd say it's a barrier to new contributors...

Copy link
Contributor

Choose a reason for hiding this comment

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

You're right, it should be. We were hoping we could get rid of these files which remove the confusion but the refactor efforts staled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add audible messages to confirm the "move block" actions.
6 participants