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

Add openOnFocus prop to AutocompleteInput #4555

Merged
merged 11 commits into from
May 21, 2024

Conversation

JoyceZhu
Copy link
Contributor

@JoyceZhu JoyceZhu commented May 2, 2024

Unblocks github/accessibility-audits#7437

The audit issue notes that when an AutocompleteInput is the first field in a form with errors (and thus when it needs to be auto-focused after submission to help the user discover and address errors), the autocomplete menu popping up automatically on focus 1) causes NVDA+Firefox to miss reading out an associated error message/FormControl.Validation even when linked via aria-describedby and 2) visually obscures the error message, which makes discovering what went wrong harder.

Offering a prop to optionally disable the menu appearing on focus improves these two users experiences; the menu will still render when the user types in the autocomplete's input field.

Changelog

New

  • Adds an openOnFocus prop which defaults to true (current behavior) to AutocompleteInput

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

@JoyceZhu JoyceZhu requested a review from TylerJDev May 2, 2024 23:53
@JoyceZhu JoyceZhu requested a review from a team as a code owner May 2, 2024 23:53
Copy link

changeset-bot bot commented May 2, 2024

🦋 Changeset detected

Latest commit: 0c1557c

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 temporarily deployed to storybook-preview-4555 May 9, 2024 12:49 Inactive
@TylerJDev
Copy link
Contributor

I wonder if we'd want up/down arrow keys to open the menu if this prop is used. For example, if you set openOnFocus to false and clear the input field, pressing up/down arrow keys will select items from the menu but doesn't show the menu itself. I'm wondering if we'd want it to show the menu by default depending on when either up/down key is used?

Copy link
Contributor

github-actions bot commented May 10, 2024

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 88.59 KB (+0.08% 🔺)
packages/react/dist/browser.umd.js 88.96 KB (+0.15% 🔺)

@github-actions github-actions bot temporarily deployed to storybook-preview-4555 May 10, 2024 03:31 Inactive
@JoyceZhu
Copy link
Contributor Author

I wonder if we'd want up/down arrow keys to open the menu if this prop is used

I think this makes sense as behavior! Let me implement that tomorrow!

Co-authored-by: Kendall Gassner <kendallgassner@github.com>
@github-actions github-actions bot temporarily deployed to storybook-preview-4555 May 13, 2024 18:01 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-4555 May 13, 2024 18:06 Inactive
@JoyceZhu JoyceZhu requested review from kendallgassner and TylerJDev and removed request for TylerJDev May 13, 2024 20:05
Copy link
Contributor

@TylerJDev TylerJDev left a comment

Choose a reason for hiding this comment

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

LGTM!

@JoyceZhu JoyceZhu added this pull request to the merge queue May 21, 2024
Merged via the queue into main with commit 9b63299 May 21, 2024
30 checks passed
@JoyceZhu JoyceZhu deleted the joycezhu/autocomplete_input_open_on_focus branch May 21, 2024 20:28
@primer primer bot mentioned this pull request May 21, 2024
khiga8 pushed a commit that referenced this pull request May 31, 2024
* Add `openOnFocus` prop to `AutocompleteInput`
Towards github/accessibility-audits#7437

* Add changeset

* Fix JSON formatting

* Allow up and down to open menu if not already open

* update hook

* Update packages/react/src/Autocomplete/AutocompleteInput.tsx

Co-authored-by: Kendall Gassner <kendallgassner@github.com>

---------

Co-authored-by: Kendall Gassner <kendallgassner@github.com>
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.

None yet

3 participants