Skip to content
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

fix(a11y): have unique ids for favorite/recent lists #2485

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

mxschmitt
Copy link

There are two distinct a11y bugs which are related to each-other:

  1. The main input .DocSearch-Input contains aria-controls="docsearch-recentSearches-list docsearch-favoriteSearches-list" which is not compliant because the recentSearches or favoriteSearches 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.
  2. When there is a Recent and a Favourite results list is shown, they share the same underlying id="docsearch-list". This PR addresses that and adds a test for both issues.

Investigation

This seems to render the search list here:

Which calls <ul {...props.getListProps()}> here:

<ul {...props.getListProps()}>

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:

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.

Copy link

netlify bot commented Feb 4, 2025

👷 Deploy request for docsearch pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 948c219

@mxschmitt mxschmitt force-pushed the test/recent-favorite-duplicate-id branch from 73b5d37 to e25c72b Compare February 4, 2025 15:05
@mxschmitt
Copy link
Author

Status: Depends on a new version autocomplete - will rebase once algolia/autocomplete#1302 has been released.

@mxschmitt
Copy link
Author

Should be ready for review @shortcuts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant