Skip to content

Commit a5c6977

Browse files
authored
Updating docs copy for accessibility false positives (#4856)
* Updating docs copy to mention how to supress accessbility false positives * address review comments * Make example less storybook specific * fix syntax coloring
1 parent c9d9e7d commit a5c6977

File tree

4 files changed

+60
-3
lines changed

4 files changed

+60
-3
lines changed

packages/@react-aria/select/docs/useSelect.mdx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -521,8 +521,16 @@ In right-to-left languages, the select should be mirrored. The arrow should be o
521521
and the selected value should be on the right. In addition, the content of list options should
522522
flip. Ensure that your CSS accounts for this.
523523

524-
### False positive on `<HiddenSelect />` in accessibility tools
524+
## Accessibility
525525

526-
When using &lt;<TypeLink links={docs.links} type={docs.exports.HiddenSelect} />&gt; some accessibility tools such as AXE or pa11y might give a false positive.
527-
The data attribute `data-rsp-a11y-ignore` is included on the hidden select element and can be used to ignore the false positives in these tools.
526+
### False positives
528527

528+
The HiddenSelect may trigger a [known accessibility false positive](https://github.com/adobe/react-spectrum/wiki/Known-accessibility-false-positives#picker)
529+
from automated accessibility testing tools. This is because the HiddenSelect is included to specifically aid with browser form autocomplete
530+
and is hidden from screen readers via `aria-hidden` since users don't need to interact with it. We manage focus internally
531+
so that focusing this hidden select element will always shift focus to the Select's trigger button instead. Automated accessibility testing tools have no way of
532+
knowing that we manage the focus in this way and thus throw this false positive.
533+
534+
To facilitate the suppression of this false positive, the `data-a11y-ignore="aria-hidden-focus"` data attribute is automatically applied to the
535+
problematic element and references the relevant `AXE` rule. Please use this data attribute to target the problematic element and exclude it
536+
from your automated accessibility tests as shown [here](./accessibility.html#false-positives).

packages/@react-spectrum/picker/docs/Picker.mdx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,3 +464,17 @@ function Example() {
464464
);
465465
}
466466
```
467+
468+
## Accessibility
469+
470+
### False positives
471+
472+
Picker may trigger a [known accessibility false positive](https://github.com/adobe/react-spectrum/wiki/Known-accessibility-false-positives#picker)
473+
from automated accessibility testing tools. This is because we include a visually hidden select element alongside the Picker to specifically aid with browser form autocomplete
474+
and hide it from screen readers via `aria-hidden` since users don't need to interact with the hidden select. We manage focus internally
475+
so that focusing this hidden select will always shift focus to the Picker's trigger button element instead. Automated accessibility testing tools have no way of
476+
knowing that we manage the focus in this way and thus throw this false positive.
477+
478+
To facilitate the suppression of this false positive, the `data-a11y-ignore="aria-hidden-focus"` data attribute is automatically applied to the
479+
problematic element and references the relevant `AXE` rule. Please use this data attribute to target the problematic element and exclude it
480+
from your automated accessibility tests as shown [here](../react-aria/accessibility.html#false-positives).

packages/dev/docs/pages/react-aria/accessibility.mdx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,24 @@ All React Aria components are tested across a wide variety of devices, browsers,
104104
* [NVDA](https://www.nvaccess.org) on Windows in Firefox and Chrome
105105
* [VoiceOver on iOS](https://www.apple.com/accessibility/iphone/vision/)
106106
* [TalkBack](https://www.android.com/accessibility/) on Android in Chrome
107+
108+
### False positives
109+
110+
There are a number of known accessibility false positives in React Aria and React Spectrum, currently documented here in our [wiki](https://github.com/adobe/react-spectrum/wiki/Known-accessibility-false-positives).
111+
These are commonly caught by automated accessibility testing tools and can cause unnecessary noise in your own accessibility audits.
112+
To facilitate the suppression of these false positives, the data attribute `data-a11y-ignore` is included on the problematic elements
113+
with the relevant `AXE` rule set as its value. Below is a list of the currently available data selectors and their equivalent `AXE` rules:
114+
115+
```tsx
116+
{
117+
rules: [
118+
{
119+
id: 'aria-hidden-focus',
120+
selector: 'body *:not([data-a11y-ignore="aria-hidden-focus"])'
121+
}
122+
]
123+
}
124+
```
125+
126+
This set of rules should be included in your accessibility test framework's `AXE` config, such as in the [automated Storybook test runner](https://storybook.js.org/docs/7.1/react/writing-tests/accessibility-testing#a11y-config-with-the-test-runner)
127+
or for the [Storybook a11y addon](https://storybook.js.org/docs/7.1/react/writing-tests/accessibility-testing#global-a11y-configuration).

packages/react-aria-components/docs/Select.mdx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,3 +1017,17 @@ function MySelect(props) {
10171017
);
10181018
}
10191019
```
1020+
1021+
## Accessibility
1022+
1023+
### False positives
1024+
1025+
Select may trigger a [known accessibility false positive](https://github.com/adobe/react-spectrum/wiki/Known-accessibility-false-positives#picker)
1026+
from automated accessibility testing tools. This is because we include a visually hidden select element alongside the Select to specifically aid with browser form autocomplete
1027+
and hide it from screen readers via `aria-hidden` since users don't need to interact with the hidden select. We manage focus internally
1028+
so that focusing this hidden select will always shift focus to the Select's trigger button instead. Automated accessibility testing tools have no way of
1029+
knowing that we manage the focus in this way and thus throw this false positive.
1030+
1031+
To facilitate the suppression of this false positive, the `data-a11y-ignore="aria-hidden-focus"` data attribute is automatically applied to the
1032+
problematic element and references the relevant `AXE` rule. Please use this data attribute to target the problematic element and exclude it
1033+
from your automated accessibility tests as shown [here](./accessibility.html#false-positives).

0 commit comments

Comments
 (0)