-
Notifications
You must be signed in to change notification settings - Fork 1.1k
USWDS - Bug: Fix invalid aria role in validator list items #4914
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
Conversation
@mejiaj I wasn't sure how best to work with the previously merged PR, so I simply brought in the changes from that PR into this branch. Please let me know if there is a cleaner path. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on our testing, let's try using an aria label on the list items to improve how it gets announced via screenreader.
@mejiaj I made some updates to improve the readout in VoiceOver. Surprisingly, an |
@amyleadem it does read better in voiceover! The only thing I've noticed is that the list item doesn't read out the updated status when I tab to it. Instead, it will just read the requirements without the current status. The only way I can get the status to be read is to focus out and back in to the input element. |
@mejiaj Switched it up a bit and generated an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works well, on VoiceOver I was able to verify functionality has improved:
- Elements read correctly
- Validation requirements update and read properly
Component also still works when inserting dynamically.
I've added some suggestions for improving code and some questions about aria attributes on the input element.
@mejiaj The current proposed solution also generates an The only concern I have is that creating a fully new text element might be too clumsy and cause some unexpected problems. It would be great to hear your thoughts. Additionally, I created an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@amyleadem it does read better. Added some thoughts below.
Overall, if we want the new status element we would have to link it to the input (which seems to be performing the same function as the list with aria-live="polite"
).
I do see the potential of this improving the experience, especially after seeing GovUKs character count recommendations in #4714. If we want to go that route we'd probably need to:
- Link the input to this new status via a unique ID and
aria-describedby
- Set a delay on the status so it can finish reading user input and then give status
@mejiaj Tasks completed: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, the experience has improved for users on screen readers with the delayed announcement.
Added some suggestions we could use to improve code readability.
let statusComplete = "status complete"; | ||
let statusIncomplete = "status incomplete"; | ||
let checkboxContent = `${validatorCheckbox.textContent} `; | ||
|
||
if (el.hasAttribute("data-validation-complete")) { | ||
statusComplete = el.getAttribute("data-validation-complete"); | ||
} | ||
|
||
if (el.hasAttribute("data-validation-incomplete")) { | ||
statusIncomplete = el.getAttribute("data-validation-incomplete"); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could simplify this by having these labels as a backup in case the dataset comes back null or undefined.
let statusComplete = "status complete"; | |
let statusIncomplete = "status incomplete"; | |
let checkboxContent = `${validatorCheckbox.textContent} `; | |
if (el.hasAttribute("data-validation-complete")) { | |
statusComplete = el.getAttribute("data-validation-complete"); | |
} | |
if (el.hasAttribute("data-validation-incomplete")) { | |
statusIncomplete = el.getAttribute("data-validation-incomplete"); | |
} | |
const statusComplete = el.dataset.validationComplete || "status complete"; | |
const statusIncomplete = el.dataset.validationIncomplete || "status incomplete"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clean! Updated in aea87ce
((debounce(() => { | ||
statusSummaryContainer.textContent = statusSummary; | ||
}, 1000)))(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional because we have the comment, but we can increase readability by extracting it to it's own updateSRSummary()
and just calling it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that it could make it more consistent with the new character count setup. Updated in bfbfd52
(If I misunderstood your request, feel free to fix while I am out!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works well, tested for regressions and VoiceOver. Has a debounce function that was introduced in PR #4976.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice discussion and nice work!
Summary
Updated the validation component so that users of assistive technologies can receive status updates about the completion of each validation requirement. This was done by adding a script that generates appropriate ARIA attributes.
Details
Added a script that generates an aria-label for each checklist item. This allows assistive technologies users to navigate to each checklist item and receive the current status of each validation requirement.
Added a script that generates a new span to house the summary of the validation status updates. This span has
aria-live
andaria-atomic
attributes so that users of assistive technologies will be notified of status changes.Removed the
aria-checked
attribute from list items in the validation component. This attribute is no longer needed now that a text element informs the user if the requirement is complete or incomplete.Added
data-validation-complete
anddata-validation-incomplete
attributes so that users can customize copy forstatus complete
andstatus incomplete
messages.Related issue
Closes: #4905
Related PRs: This PR incorporates the changes originally merged in #4719 that were later reverted in #4906. This PR includes the original update from #4719 and resolves the errors that caused the reversion.
Preview link
Preview link: Validation component
Problem statement
Including the aria-checked attribute generates errors
Adding the
aria-checked
attribute to a<li>
item results in the following a11y error:These errors reveal that items with the
aria-checked
attribute also need an appropriate role. Reference: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-checked#associated_rolesHowever, adding
role="checkbox"
to the<li>
item also returns an error:VoiceOver produces a confusing readout
Additionally, VoiceOver generates undesirable and inconsistent readouts. Items can be read twice or only partially.
Solution
aria-checked
The
data-checklist-label
element now informs the keyboard user if the validation requirements are complete or incomplete. There is no longer a need to use an attribute likearia-checked
to communicatecomplete
orincomplete
to the user.Confusing readout
Changing the following items generated a more consistent readout in VoiceOver:
aria-label
for each checklist item that includes the original text content plus the item's current statusaria-live
andaria-atomic
attributes that houses the summary of all checklist items plus their individual statuses.Tasks completed in this PR:
cm-validation-a11y
branch 0684b17aria-checked
attribute from the list item f077275tabindex="0"
to make the items in the validation checklist items easier to navigate via tab 29c2b61aria-live
andaria-atomic
attributes that houses a status summary 07ad7dedata-validation-complete
anddata-validation-incomplete
attributes eeb2e18Testing and review
Using the screen readers you have available,
.usa-input
and confirm that the status message indata-checklist-label
updates accordingly:Tested on:
Before opening this PR, make sure you’ve done whichever of these applies to you:
git pull origin [base branch]
to pull in the most recent updates from your base and check for merge conflicts. (Often, the base branch isdevelop
).npm test
and confirm that all tests pass.