-
Notifications
You must be signed in to change notification settings - Fork 3
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
Address all pa11y violations in cypress testing. #834
Conversation
…st. Hide `.usa-step-indicator` gtom testing.
This write-up is 💯. Really great to spell everything out. I'm going to dig into the details in a bit, but a couple things I wanted to note:
For contrast violations, the violation pretty much is the issue. It's considering people who are sighted, but may be color-blind, or have other issues with their vision. As much as possible, we should try to fix these (if that means making a React-USDWS PR, maybe we do that...
One thing to test here is whether adding the "upload complete" status causes a screen reader to announce each upload as it completes. Because there's no limit to how many docs a user can attach, we wanted to avoid having the reader call out every file. |
I agree we should try to fix this, although I'm not sure if that would be in the scope of this PR. My reasoning is that, this violation is coming from the React USWDS component, not any code we wrote, and seems to be able to pass 508 testing. It might be something with
It doesn't from my testing, but I'm new to VO so anther go at it from someone else would be great! 😀 |
@@ -42,7 +42,7 @@ export const FieldTextarea = ({ | |||
<PoliteErrorMessage>{meta.error}</PoliteErrorMessage> | |||
)} | |||
{hint && ( | |||
<div aria-labelledby={id} className="usa-hint margin-top-1"> | |||
<div role="note" aria-labelledby={id} className="usa-hint margin-top-1"> |
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.
In the spirit of unifying our re-useable form components could you please add the role=note
to the other XXField components as well please. We have the exact same time of hint handling for FieldDropdown FieldTextInput looks like.
re: react-uswds
re: dl/dt issue with the Grid
|
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. Let's ship. I might just copypaste the ignore versus threshold versus hideElement guidance into docs/ADR too i think you basically wrote a mini decision record about how to triage pa11y errors.
OY2-16586
Summary
Thoughts on pa11y options if a fix is not found.
ignore
This option in pa11y, in my opinion, should be used sparingly. Ignoring rules will ignore all violations, current and future, of this type and will run into issues with legitimate violations being overlooked.
For example
<Fieldsets>
component will showaria-allowed-attr
violations whenaria-required
is present and using its implicitgroup
role so to let the user know, in VO, this is a required group. If we ignore this type of violation then in the case where<Fieldsets>
contained radios, but wasn’t assigned theradiogroup
role ignoring this violation type would overlook an easy fix of assigning theradiogroup
role. Not only did this fix the violation, but VO is more descriptive when describing this group.So how do we deal with the above example when we cannot use a role that allows the
aria-required
attribute? This is where we would use thethreshold
option. Seethreshold
bullet point for more details.The only case I used the
ignore
option was for the<dl>
,<dt>
and<dd>
violations with structure in theDoubleColumnGrid
component. See theIssue
bullet point below for more details.hideElement
Hide elements from pa11y tests when the element is a part of a third party component, where child elements are NOT passed in and the component is not extensively altered. The
<StepIndicator>
and<StepIndicatorStep>
are good examples of components where we can ignore elements. SeeIssue
below for more details.This assumes that the third library component has been accessibility tested. We are using React USWDS components, which I believe some components are being tested for accessibility.
We should test the components ourselves anyways just to make sure there are no actual violations before hiding.
threshold
ignore
a violation and should not hide the element.Again with
<Fieldset>
example, see example inIgnore
bullet point, when the element contains other elements that are not radios. For example date selection/input, there is no role that accommodates a complicated widget like this and the implicitgroup
role does not permitaria-required
attribute. In this case we could use Ignore, but the better option would be to addthreshold
counts to bypass the violation. This ensures that we address each new violation and either find a fix or add to thethreshold
.My conclusion on these pa11y options is that they should all be used sparingly and each violation needs to be carefully investigated before excluding them from tests. From my investigation some violations do not cause issues in VO, but fixing them did improve VO and that is the goal.
Issue: definition-list & dlitem - DoubleColumnGrid
After investigating these two violations, the cause is the
DoubleColumnGrid
component that has<dt>
and<dd>
nested in three<div>
layers within the<dl>
element. According to the docs on<dl>
, you can nest<dt>
and<dd>
elements within one<div>
layer, but nothing suggests nesting in two or more layers is acceptable or not. The second violation I suspect was due to the deep nesting of the<dt>
and<dd>
elements in<divs>
. Testing VO and checking the accessibility tree on chrome shows no issues with accessibility.Two possible solutions were refactoring the
DoubleColumnGrid
to address this issue or using pa11y options to ignore/hide/threshold the violation. I chose the later.Ignore
,hideElement
, orthreshold
the violation? My choice was toignore
the violation for the specific test, because theDoubleColumnGrid
component is being passed child elements, which if you hid the component, would ignore all potentially valid violations from child elements. Threshold would work, but adding more children elements to this component would require increasing the threshold for each additional child. Since we know the error is a structure issue and adding children doesn’t alter the structure pattern and accessibility is not hindered, we can assume the violations should be the same type.We will need to keep in mind to revisit this violation in case any
<dl>
element is added to these tests that are not a part of theDoubleColumnGrid
component.Github issue going over the spec
<dl>
change to allow<div>
wrapping<dt>
&<dd>
. Reconsider FAQ: <di>, <div> or <li> wrapping <dt> and <dd> whatwg/html#1937<dl>
element spec https://html.spec.whatwg.org/multipage/grouping-content.html#the-dl-elementIssue: aria-allowed-attr & color-contrast - DynamicStepIndicator
DynamicStepIndicator uses React USWDS
StepIndicator
andStepIndicatorStep
components with minimal customization. I suspect the Aria attribute error is due to the element not having a role which allows thearia-label
attribute. Possibly make a PR on React USWDS to add a role? The color contrast error is the<span>
element containing the step indicator step text is more complicated and will probably need more investigation. From VO accessibility testing, neither of these violations caused issues.The decision was to hide both from testing. This choice was made because the
DynamicStepIndicator
component has minimal customization, no child elements passed in and VO testing worked fine. I recommended someone on React USWDS to look into these violations.Issue: aria-allowed-attr - FileUpload
This error was due to
<span>
not having a role that permits thearia-labelledby
attribute. Adding a role ofgroup
to the<span>
fixed the violation.Issue: aria-allowed-attr - FieldSet
The cause of the violation is that the implicit
aria-role
role ofgroup
for<Fieldset>
does not supportaria-required
. The<Fieldset>
React USWDS component is composed of a<fieldset>
element. Thearia-required
prop is passed to this element.The solution I chose was to give
<Fieldset>
containing<FieldRadio>
components the role ofradiogroup
, this takes care of the violation in these elements and VO is more descriptive as a result. The leftover violations will be addressed usingthresholds
instead ofhideElements
andignore
options in pa11y.The reason for using the
threshold
option is because usingignore
for violation type is too broad and would overlook actual violations and fixes like above with radios. Hiding the<Fieldset>
element is would hide any children element passed into it of which there are many.Docs on
. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/fieldsetDocs on aria role
group
. https://w3c.github.io/aria/#groupIssue: aria-allowed-attr - FileListItem
The
aria-valuetext
is usingstatusValue
prop as it’s value. When uploads are finished thestatusValue
is an empty string, which causes the invalid values issue. Adding an additional status of ‘upload complete’ to be passed tostatusValue
fixed the violation.Issue: aria-allowed-attr - FieldTextarea
This violation is caused by the
<div>
, containing thehint
prop, needing a valid role to be permitted to usearia-labelledby
.The solution was to give the
<div>
a role that is allowed to use thearia-labelledby
. Thenote
role was the best match for our use case.Test cases covered
dashboard.spec.ts
contacts.spec.ts
contractDetails.spec.ts
documents.spec.ts
newSubmissionSpec.ts
rateDetails.spec.ts
QA guidance
Please test VO on the changes done to some elements.
<Fieldsets>
that contain<FieldRadio>
.area-valuetext
for listed uploaded items when completed.