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: allow tabbing away from controlled auto-suggest without opening menu #2310

Merged
merged 5 commits into from Oct 10, 2019

Conversation

@hchokshi
Copy link
Member

commented Oct 9, 2019

Description

Removes default (update input value and re-focus to input) handling for tab keypress to move out of AutoSuggest component. Allows the user to tab away from a controller auto suggest component without opening the suggestions.

Motivation & context

Resolves #2309. Makes AutoSuggest more accessible.

Issue type checklist

  • Chore: A change that does not impact distributed packages.
  • Bug fix: A change that fixes an issue, link to the issue above.
  • New feature: A change that adds functionality.

Is this a breaking change?

  • This change causes current functionality to break.

Process & policy checklist

  • I have added tests for my changes.
  • I have tested my changes.
  • I have updated the project documentation to reflect my changes.
  • I have read the CONTRIBUTING documentation and followed the standards for this project.
@janechu

This comment has been minimized.

Copy link
Member

commented Oct 9, 2019

Could you add a test for this in the auto-suggest.spec.tsx? I would suggest that the test makes sure that default is not prevented, or that focus is now on the next tab-able element and that invoke has not been triggered.

hchokshi added 2 commits Oct 9, 2019
@hchokshi

This comment has been minimized.

Copy link
Member Author

commented Oct 9, 2019

I tried testing focus being passed to an adjacent element (with onFocus event handler, or document.activeElement + ref), but it seems this is not testable in Jest as simulating keypresses won't trigger default behaviour that would be expected for explicit user input for security reasons (to prevent JavaScript from pretending to be the user).

https://stackoverflow.com/a/1601732

@janechu
janechu approved these changes Oct 9, 2019
@janechu

This comment has been minimized.

Copy link
Member

commented Oct 9, 2019

No worries, this looks good to me, thanks!

@scomea
scomea approved these changes Oct 10, 2019
nicholasrice and others added 2 commits Oct 10, 2019
@janechu janechu merged commit a5f5a99 into microsoft:master Oct 10, 2019
3 checks passed
3 checks passed
ci/circleci: build_dependencies Your tests passed on CircleCI!
Details
ci/circleci: test_coverage Your tests passed on CircleCI!
Details
license/cla All CLA requirements met.
Details
@hchokshi hchokshi deleted the hchokshi:fix/auto-suggest-controlled-tab branch Oct 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.