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: add accessibility updates to amount field #7692

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

JoshuaHungDinh
Copy link
Contributor

@JoshuaHungDinh JoshuaHungDinh commented Jan 24, 2025

Resolves:
Accessibility Audit: Give-033 & - Give-044

https://lw.slack.com/archives/C0355E6LBMZ/p1736794600442929

Description

This PR includes a couple updates for the amount field template.

  • An aria-label attribute for the field, as it lacks a corresponding <label>.
  • An aria-describedBy attribute for the field to match the field error when present.
  • Use of refs to focus the field when an amount error occurs.

Affects

  • Custom Amount field on Donation Forms.

Visuals

Screen.Recording.2025-01-27.at.10.06.34.AM.mov

Testing Instructions

  • View a form.
  • Check the console and verify that the custom amount field is properly labeled with an aria-label attribute.
  • Set a minimum amount on the donation form.
  • Process a donation with an amount less than the minimum.
  • Verify that when an error occurs the amount field is focused and properly described by the error id.

Pre-review Checklist

  • Acceptance criteria satisfied and marked in related issue
  • Self Review of code and UX completed

@JoshuaHungDinh JoshuaHungDinh marked this pull request as ready for review January 24, 2025 07:34
@JoshuaHungDinh JoshuaHungDinh changed the title Fix: add aria-label to custom amount field Fix: add accessibility updates to amount field Jan 27, 2025
return (
<div className={classNames('givewp-fields-amount__input-container', {invalid: fieldError})}>
<CurrencyInput
ref={(input) => {
if (input && fieldError) {
input.focus();
Copy link
Contributor

@jonwaldstein jonwaldstein Feb 7, 2025

Choose a reason for hiding this comment

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

hmm, i'm pretty sure react-hook-form handles this for us or at least provides a way of doing this for custom inputs. I know it works properly for other fields since we're using shouldFocusOnError by default. Might want to check the discussion forums https://github.com/orgs/react-hook-form/discussions?discussions_q=is%3Aopen+shouldFocusError

There's also a react-hook-form helper setFocus

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

Successfully merging this pull request may close these issues.

2 participants