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 aria-pressed attribute to all toggleVisibility buttons #2232

Merged
merged 1 commit into from
Dec 19, 2021
Merged

Add aria-pressed attribute to all toggleVisibility buttons #2232

merged 1 commit into from
Dec 19, 2021

Conversation

patrickhlauke
Copy link
Contributor

@patrickhlauke patrickhlauke commented Dec 18, 2021

Type of change

  • Bug fix
  • New feature development
  • Tech debt (refactoring, code cleanup, dependency upgrades, etc)
  • Build/deploy pipeline (DevOps)
  • Other

Objective

Currently, the show/hide buttons to toggle the visibility of passwords/hidden fields don't expose their state to assistive technologies - they only change visually by swapping out the fontawesome icon used. Adding aria-pressed="false"/aria-pressed="true" makes these proper toggle buttons, whose state is exposed to assistive tech. This way a screen reader user can hear whether the password/hidden field is visible or not visible.

Closes #2228

Code changes

For all the various toggleVisibility buttons used, adds [attr.aria-pressed] referencing the relevant value (e.g. showPassword). Toggling the button dynamically changes the value of the attribute that's rendered.

Screenshots

No UI change

Testing requirements

Test with a screen reader (e.g. NVDA). Alternatively, check that the aria-pressed attribute in the DOM is present and correctly toggles between literal true and false values (true when the password is visible and the icon is fa-eye-slash, false when the password is hidden and the icon is fa-eye)

Before you submit

  • I have checked for linting errors (npm run lint) (required)
  • This change requires a documentation update (notify the documentation team)
  • This change has particular deployment requirements (notify the DevOps team)

@patrickhlauke
Copy link
Contributor Author

Comparison video (using a test item) of navigating to a toggle button and triggering it - currently, and after this PR, using NVDA on Windows.

Currently, note that it simply announces it as Toggle visibility button Toggle visibility (the second "Toggle visibility" is caused by the title attribute). No indication of current state. Toggling the button leads to no announcement by the screen reader either.

After the PR, the toggle is announced as either "pressed" or "not pressed" when first focusing it, exposing the current state. Toggle Visibility toggle button not pressed Toggle Visibility
Toggling the control leads to announcements of "pressed" and "not pressed" to reflect the change that just happened. Returning to the control announces its correct current state.

bitwarde-issue2228.mp4

@djsmith85 djsmith85 self-assigned this Dec 19, 2021
Copy link
Contributor

@djsmith85 djsmith85 left a comment

Choose a reason for hiding this comment

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

@patrickhlauke Thank you for your contribution 🚀. Code changes look good and tested it with NVDA on Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A11y: Toggle visibility buttons don't programmatically expose their state
2 participants