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

Accessibility: Plugin favorites button incorrectly coded as link, doesn't have a consistent accessible name, and loses focus when activated #266

Open
amberhinds opened this issue Apr 16, 2024 · 3 comments
Labels
Accessibility Issues related to keyboard navigation, screen readers, etc [Site] Plugins

Comments

 @amberhinds
Copy link

On the plugin single test page ( Gutenberg plugin test page ) and also on the current live plugin single ( Accessibility Checker example ) there are three accessibility problems with the button to favorite the plugin.

Accessibility Issues

  1. This is incorrectly coded as a link instead of a button.
  2. The accessible name changes.
  3. When activating the favorites button, the page reloads and focus in not set on the element.

Screenshot of the element:

 Screenshot with arrow pointing to element. It is next to the download link on the plugin single.

Element Code

This is the current code from the Gutenberg test page:

 <div class="plugin-favorite"> <a href=" https://test.wordpress.org/plugins/wp-json/plugins/v1/plugin/gutenberg/favorite?_wpnonce=490b4e5bd7&amp ; favorite=1" class="plugin-favorite-heart"> <span class="screen-reader-text"> Favorite Gutenberg		</span> </a> </div>

When the plugin is favorited, the accessible name (in this case, added as screen reader text) changes:

 <div class="plugin-favorite"> <a href=" https://test.wordpress.org/plugins/wp-json/plugins/v1/plugin/gutenberg/favorite?_wpnonce=490b4e5bd7&amp ; unfavorite=1" class="plugin-favorite-heart favorited"> <span class="screen-reader-text"> Unfavorite Gutenberg		</span> </a> </div>

Detailed problem explanation

Incorrect Role

This element has an incorrect role - links go somewhere; buttons do something. This should be a button, not a link. Having it as a link is especially confusing because if I go to the Favorites button with a screen reader, instead of hearing something like "Button, Favorite Guttenberg, Pressed" I hear "Visited, link, Unfavorite Gutenberg, article."

Inconsistent Accessible Name

It can be very confusing for screen reader users if the name of an element changes. Users don't expect labels to change on elements and may look for the original label but be unable to find it.

Rather than changing the screen reader text from "Favorite Gutenberg" to "Unfavorite Gutenberg," this should be coded as a toggle button that indicates if it has been pressed or not with aria. That way the screen reader text does not need to change.

@alexstine may have additional thoughts about this.

Loss of Focus on Activation

Because this is a link, when activated the page reloads. Screen reader users are dumped at the top of the page and need to then find their way back to this button if the want to undo the action or if they want to proceed down the page.

Recording

Here's a recording of interacting with this element and what I hear in VoiceOver:
https://github.com/WordPress/wordpress.org/assets/13153456/c9338086-39e6-41c3-96a3-26f8564e2f4b

Recommendation

In an ideal world this would be rebuilt with a button tag. If that is not possible, it can have role="button" added to it and a spacebar handler added so that it function as a button (buttons should be able to be triggered with the spacebar and return key). See role=button documentation .

The accessible name should always be "Favorite $Plugin-Name" and then you use aria-pressed to indicate if it's been set as favorite or not.

Ideally, this would activate with JavaScript and not require a page reload. If the page reload is kept, then there should be something that returns keyboard focus to the button on reload of the page.

 @amberhinds
Copy link
Author

There's also a color contrast issue with this element but I opened that as a separate issue for the redesign: #265

 @ryelle ryelle added Accessibility Issues related to keyboard navigation, screen readers, etc [Site] Plugins labels Apr 16, 2024
 @amberhinds
Copy link
Author

Darn, I just realized that my recording didn't get the screen reader audio, but you can read what it's saying on the speech viewer on the page. If anyone wants me to re-record, let me know and I'll post a new video.

 @amberhinds
Copy link
Author

There was conversation about adding a tool-tip to this button starting here: #265 (comment)

It brought to my attention that in 15 years of using WordPress I have never understood what this does or how to even view my favorites.

I think it might be better for users if this button triggered an accessible modal with two things:

  • Favorite Plugin button
  • View Your Favorites link

This is something similar that we did for a client site a while ago. It's more complex than we need (it has checkboxes because they can have multiple places to save things), but this is what I mean by a modal.
 Screenshot 2024-04-17 at 9 30 55 AM

Sign up for free to join this conversation on GitHub . Already have an account? Sign in to comment
Labels
Accessibility Issues related to keyboard navigation, screen readers, etc [Site] Plugins
Projects
None yet
Development

No branches or pull requests

2 participants