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

Send Message A11Y Audit - Error messages not reading correctly in VoiceOver #2124

Closed
7 tasks
jonathanbobel opened this issue Nov 18, 2024 · 0 comments · Fixed by #2192
Closed
7 tasks

Send Message A11Y Audit - Error messages not reading correctly in VoiceOver #2124

jonathanbobel opened this issue Nov 18, 2024 · 0 comments · Fixed by #2192
Assignees

Comments

@jonathanbobel
Copy link
Contributor

jonathanbobel commented Nov 18, 2024

Issue: Error Messages Not Properly Announced When Using VoiceOver

Problem:
When an error is triggered during form interaction and VoiceOver is enabled, the focus moves to the Skip Link instead of the error message. This causes the error message to not be read aloud, leaving users unaware of the issue.


Steps to Reproduce:

  1. Enable VoiceOver on macOS.
  2. Trigger a validation error (e.g., leave a required field blank or enter invalid data).
  3. Observe that:
    • The focus moves to the Skip Link.
    • The error message is not announced by VoiceOver.

Expected Behavior:

  • When an error occurs, the following should happen:
    1. The focus moves directly to the error message or the problematic input field.
    2. The error message is announced by VoiceOver.
    3. The error is clearly associated with the input field (if applicable) for further context.

Proposed Solution:

  1. Set Focus to the Error Message

    • Ensure that focus moves programmatically to the error message when it appears.
    • Example:
      document.getElementById('error-message-id').focus();
  2. Use aria-live for Dynamic Error Messages

    • Add aria-live="assertive" to the error message container to ensure it is announced immediately by screen readers:
      <div id="error-message-id" role="alert" aria-live="assertive">
        Please enter a valid email address.
      </div>
  3. Associate Error Message with the Input Field

    • Link the error message to the relevant input field using aria-describedby:
      <label for="email">Email:</label>
      <input id="email" type="email" aria-describedby="error-message-id" required>
      <div id="error-message-id" role="alert" aria-live="assertive">
        Please enter a valid email address.
      </div>
  4. Avoid Redirecting Focus to Unrelated Elements

    • Ensure the focus does not move to unrelated elements (e.g., the Skip Link). Test and correct focus management logic in the JavaScript handling the error.
  5. Test with VoiceOver and Other Screen Readers

    • Validate the fix with VoiceOver, NVDA, and JAWS to ensure:
      • The error message is announced.
      • Focus behavior is predictable and correct.

Acceptance Criteria:

  • When a validation error occurs, focus moves directly to the error message or the problematic input field.
  • The error message is announced immediately by VoiceOver using an aria-live="assertive" region.
  • The error message is programmatically associated with the relevant input field using aria-describedby.
  • Focus does not move to unrelated elements (e.g., the Skip Link) when an error is triggered.
  • Screen reader users are able to understand the error and its context without additional navigation.
  • Fix is tested with VoiceOver (macOS) to ensure proper behavior.
  • HTML passes validation with no duplicate IDs or parsing errors related to the error-handling logic.

References:

WAI-ARIA Authoring Practices: Error Messages
USWDS Accessibility Guidance

Example Fix:

HTML:

<label for="email">Email:</label>
<input id="email" type="email" aria-describedby="email-error" required>
<div id="email-error" role="alert" aria-live="assertive">Please enter a valid email address.</div>
@jonathanbobel jonathanbobel converted this from a draft issue Nov 18, 2024
@heyitsmebev heyitsmebev moved this from ⬇ Up-Next to 🏗 In progress (WIP: ≤ 3 per person) in Notify.gov product board Dec 9, 2024
@heyitsmebev heyitsmebev linked a pull request Dec 10, 2024 that will close this issue
@github-project-automation github-project-automation bot moved this from 🏗 In progress (WIP: ≤ 3 per person) to ✅ Done in Notify.gov product board Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants