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

Fix: accessibility issue of device preview options #63958

Merged
merged 4 commits into from
Jul 30, 2024

Conversation

up1512001
Copy link
Member

What?

  • added aria-label to desktop, tablet, mobile & preview links.

Why?

Fixes #63910

Testing Instructions

  • open editor and click on view to resize now check with screenreader selected view will be accessible.

Screenshots or screencast

Screen.Recording.2024-07-26.at.01.25.23.mov

Copy link

github-actions bot commented Jul 25, 2024

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: up1512001 <[email protected]>
Co-authored-by: talldan <[email protected]>
Co-authored-by: joedolson <[email protected]>
Co-authored-by: jeryj <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@joedolson
Copy link
Contributor

Thanks for contributing! However, this change won't solve the problem in question. Adding an aria-label means that now the accessible name won't match the visible label. The intention of the ticket is to ensure that whichever of the options is currently selected is announced differently from the unselected items.

Possible solutions could include providing an accessible name for the checkbox (e.g., "selected"); adding a visible text label such as Desktop (selected); or adding an attribute like aria-pressed="true" to indicate that the state of the button is pressed.

@akasunil akasunil added [Type] Bug An existing feature does not function as intended [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). labels Jul 26, 2024
@up1512001
Copy link
Member Author

@joedolson updated aria-label by checking the selected device type.

video reference

Screen.Recording.2024-07-26.at.11.03.46.mov

@talldan
Copy link
Contributor

talldan commented Jul 26, 2024

Thanks for the PR @up1512001!

I think this UI should be implemented using the MenuItemsChoice component as it should provide the correct accessibility out of the box.

The 'Visual Editor' / 'Code Editor' options are an example of that component being used:

Screenshot 2024-07-26 at 3 37 44 PM

Screenshot 2024-07-26 at 3 39 32 PM

@up1512001
Copy link
Member Author

@talldan replaced MenuItem with MenuItemsChoice. please review the PR.

reference video

Screen.Recording.2024-07-28.at.00.33.50.mov

Copy link
Contributor

@talldan talldan left a comment

Choose a reason for hiding this comment

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

Thanks for addressing the feedback. I've left one further comment, then this should be good to ship!

Comment on lines 105 to 112
/**
* Handles the selection of a device type.
*
* @param {string} value The device type.
*/
const onSelect = ( value ) => {
setDeviceType( value );
};
Copy link
Contributor

@talldan talldan Jul 29, 2024

Choose a reason for hiding this comment

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

The changes so far look good. Right now voiceover announces that the menu item is ticked on focus which is a big improvement over what's in trunk:
Screenshot 2024-07-29 at 12 05 12 PM

But when changing the option (e.g if I select 'Tablet' now) there's no announcement that the option was changed.

So another good accessibility improvement would be to add a spoken message when an option is selected (using the speak function from the a11y package). This would let screenreader users know that something happened when they change the option.

There's an example here of how the visual/code editor mode option does this:

speak( __( 'Visual editor selected' ), 'assertive' );

Something similar could be done for the device previews, either as part of this onSelect function or within the setDeviceType action.

Copy link
Member Author

Choose a reason for hiding this comment

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

@talldan added speak on the device selection.

Copy link
Contributor

@talldan talldan left a comment

Choose a reason for hiding this comment

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

Thanks @up1512001, testing well, code looks good, this looks ready to merge

@talldan talldan merged commit dba69d0 into WordPress:trunk Jul 30, 2024
61 of 62 checks passed
@talldan talldan changed the title Fix: accessibility issue of menugroup Fix: accessibility issue of device preview options Jul 30, 2024
@github-actions github-actions bot added this to the Gutenberg 19.0 milestone Jul 30, 2024
Comment on lines +113 to +119
if ( value === 'Desktop' ) {
speak( __( 'Desktop selected' ), 'assertive' );
} else if ( value === 'Tablet' ) {
speak( __( 'Tablet selected' ), 'assertive' );
} else {
speak( __( 'Mobile selected' ), 'assertive' );
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for this PR! These announcements shouldn't be necessary. Could you remove these in a follow-up?

Copy link
Member Author

Choose a reason for hiding this comment

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

@jeryj Sure

Copy link
Member Author

Choose a reason for hiding this comment

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

@jeryj created PR to remove speak from menu selection.
#64115

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing semantics for which view option is chosen
5 participants