Skip to content

Commit

Permalink
Add accessibility controls to 'No results' list item
Browse files Browse the repository at this point in the history
Adds `role="option"` and `aria-disabled="true"` to the rendered li when no results have been found. This ensures for screen readers who navigate to the 'no results' li that they know it's still semantically part of the autocomplete interface but not a valid option.

This solution was recommended by DAC following a recent audit of the GOV.UK Design System website.
  • Loading branch information
owenatgov committed Aug 21, 2024
1 parent 47eb589 commit 929c81a
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

- [Pull request #727: Add `aria-controls` to aria props](https://github.com/alphagov/accessible-autocomplete/pull/727)
- [Pull request #724: Add accessibility controls to 'No results' list item](https://github.com/alphagov/accessible-autocomplete/pull/724)


## 3.0.0 - 2024-04-19

### Breaking changes
Expand Down
2 changes: 1 addition & 1 deletion dist/accessible-autocomplete.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/accessible-autocomplete.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/lib/accessible-autocomplete.preact.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/lib/accessible-autocomplete.preact.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/lib/accessible-autocomplete.react.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/lib/accessible-autocomplete.react.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ export default class Autocomplete extends Component {
})}

{showNoOptionsFound && (
<li className={`${optionClassName} ${optionClassName}--no-results`}>{tNoResults()}</li>
<li className={`${optionClassName} ${optionClassName}--no-results`} role='option' aria-disabled='true'>{tNoResults()}</li>
)}
</ul>

Expand Down

0 comments on commit 929c81a

Please sign in to comment.