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 12, 2024
1 parent bfe3240 commit bd31634
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 7 deletions.
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 bd31634

Please sign in to comment.