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

[Accessibility][Autocomplete] Announce "no selectable options" #5662

Merged
merged 4 commits into from
Feb 6, 2025

Conversation

kendallgassner
Copy link
Contributor

Closes #

Closes: https://github.com/github/accessibility-audits/issues/10123

Use the Announce component to announce "no selectable options" when a user filters options and there are no results in the Autocomplete component.

Changelog

New

Changed

Removed

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

Testing & Reviewing

Merge checklist

Copy link

changeset-bot bot commented Feb 5, 2025

🦋 Changeset detected

Latest commit: 632d2c8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Feb 5, 2025
Copy link
Contributor

github-actions bot commented Feb 5, 2025

👋 Hi, this pull request contains changes to the source code that github/github depends on. If you are GitHub staff, we recommend testing these changes with github/github using the integration workflow. Thanks!

Copy link
Contributor

github-actions bot commented Feb 5, 2025

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 105.52 KB (+0.1% 🔺)
packages/react/dist/browser.umd.js 105.9 KB (+0.08% 🔺)

@kendallgassner kendallgassner marked this pull request as ready for review February 5, 2025 19:32
@kendallgassner kendallgassner requested a review from a team as a code owner February 5, 2025 19:32
@github-actions github-actions bot temporarily deployed to storybook-preview-5662 February 5, 2025 19:35 Inactive
@@ -381,9 +382,9 @@ function AutocompleteMenu<T extends AutocompleteItemProps>(props: AutocompleteMe
</ActionList>
) : emptyStateText !== false && emptyStateText !== null ? (
enabled ? (
<Box className={classes.EmptyStateWrapper}>{emptyStateText}</Box>
<Announce className={classes.EmptyStateWrapper}>{emptyStateText}</Announce>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to use LiveRegion or Debounce because this does not provide feedback if a user continues to type.

debounceAnnouncement(emptyStateText as string)
}
}, [allItemsToRender])

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not Announce

I chose not to use the Announce component because it does not re-render (aka re-announce) if TextContent does not change.

Why does this matter?

Imagine my autocomplete contains
Banana, Apple, Pear

if a user types aa, no selectable options should be announced. Then if a user types another a making the input read aaa, no selectable options should be announced again.

If a user types bb, no selectable options should be announced. Then if the user presses CMD + A to highlight all text and then CMD + C to paste new text input we should hear no selectable options announced.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why Debounce

I had to pair this functionality with debounce so that when a user types rapidly, we do not hear too much feedback

Copy link
Contributor

@camertron camertron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems ok to me!

@kendallgassner kendallgassner added this pull request to the merge queue Feb 6, 2025
Merged via the queue into main with commit 613cf0c Feb 6, 2025
44 checks passed
@kendallgassner kendallgassner deleted the kendallg/Autocomplete branch February 6, 2025 21:43
@primer primer bot mentioned this pull request Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants