fix(a11y): have unique ids for favorite/recent lists #2485
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There are two distinct a11y bugs which are related to each-other:
.DocSearch-Input
containsaria-controls="docsearch-recentSearches-list docsearch-favoriteSearches-list"
which is not compliant because therecentSearches
orfavoriteSearches
elements do not exist all the time in the DOM. Only if existing favorites or recent searches they should be added - see Ensures all ARIA attributes have valid values (#docsearch-input): A11y_Playwright OSS releases_Saerch_AI4W microsoft/playwright.dev#1628. The fix for this is in fix(autocomplete): filter out empty collections in aria-controls autocomplete#1302.id="docsearch-list"
. This PR addresses that and adds a test for both issues.Investigation
This seems to render the search list here:
docsearch/packages/docsearch-react/src/StartScreen.tsx
Line 49 in aa666de
Which calls
<ul {...props.getListProps()}>
here:docsearch/packages/docsearch-react/src/Results.tsx
Line 31 in 7f670b6
Which gets its value from a different package:
https://github.com/algolia/autocomplete/blob/f05a701724d75fc3ade5e49c93d23077fb200371/packages/autocomplete-core/src/getPropGetters.ts#L302
And reads its value from here:
docsearch/packages/docsearch-react/src/DocSearchModal.tsx
Line 131 in db8edeb
So it looks like
getListProps
reads source only from the passed parameters. This PR passes the source over in the params.Thanks for the review. Max.