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

Cannot select accessible listbox options #469

Closed
luistak opened this issue Oct 20, 2020 · 1 comment · Fixed by #473
Closed

Cannot select accessible listbox options #469

luistak opened this issue Oct 20, 2020 · 1 comment · Fixed by #473

Comments

@luistak
Copy link
Collaborator

luistak commented Oct 20, 2020

Envs

  • @testing-library/user-event version: ^12.1.7

  • Testing Framework and version: Jest@24.9.0

  • DOM Environment: jsdom 16

Relevant code or config

https://codesandbox.io/s/silent-brook-ksldl?file=/src/App.js

What you did:

Tried to use selectOptions in with a custom select using Downshift useSelect hook

What happened:

It did not work as expected selecting the right options

Reproduction repository:

https://codesandbox.io/s/silent-brook-ksldl?file=/src/App.js

Problem description:

When trying to use the selectOptions API using a non-native select, the current selector does not match accessible compatible roles

Suggested solution:

Change this line to

Array.from(select.querySelectorAll("option, [role='option']"));
@luistak
Copy link
Collaborator Author

luistak commented Oct 21, 2020

The #470 PR was incomplete when selecting a non-native accessible listbox we can't handle like a normal option

There small differences:

  • Option values need to be compared with innerHTML instead of value
  • When selecting the option we need to change the aria-selected property instead of selected
  • We need to click instead of firing an input event

I'm going to open a new pr with those fixes, can you please re-open this issue @kentcdodds?

@kentcdodds kentcdodds reopened this Oct 21, 2020
@luistak luistak linked a pull request Oct 22, 2020 that will close this issue
4 tasks
@luistak luistak closed this as completed Oct 22, 2020
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 a pull request may close this issue.

2 participants