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 VoiceOver bug for Listbox component in Chrome #2824

Merged
merged 2 commits into from Nov 2, 2023
Merged

Conversation

RobinMalfait
Copy link
Collaborator

Chrome currently has a bug if you use a Listbox with a Label and use the aria-multiselectable attribute. This combination will cause VoiceOver to not announce the role="option" elements when interacting with them.

If we drop the aria-multiselectable OR the aria-labelledby it starts working. Alternatively replacing aria-labelledby with aria-label won't work either.

I filed a Chrome bug report about this here: https://bugs.chromium.org/p/chromium/issues/detail?id=1498261


Luckily there is a workaround in our Listbox implementation. Right now we always require the Listbox.Button to be there. The Listbox.Options component doesn't work on its own in our implementation.

This means that whenever we open the Listbox that we have to go via the Listbox.Button. This Listbox.Button is already labelled by the Listbox.Label if there is one.

This also means that we can safely drop the id of the label inside the aria-labelledby from the Listbox.Options.

This wouldn't have worked if our Listbox.Options could be used in a standalone way without the Listbox.Button.

At the end of the day the hierarchy looks like this:

  • Options is labelled by the Button
    • Button is labelled by the Label
      • Label

Fixes: #2817

Chrome currently has a bug if you use a `Listbox` with a `Label` and use
the `aria-multiselectable` attribute. This combination will cause
VoiceOver to _not_ announce the `role="option"` elements when
interacting with them.

If we drop the `aria-multiselectable` OR the `aria-labelledby` it starts
working. Alternatively replacing `aria-labelledby` with `aria-label`
won't work either.

I filed a Chrome bug report about this here: https://bugs.chromium.org/p/chromium/issues/detail?id=1498261

---

Luckily there is a workaround in our `Listbox` implementation. Right now
we always require the `Listbox.Button` to be there. The
`Listbox.Options` component doesn't work on its own in our
implementation.

This means that whenever we open the `Listbox` that we have to go via
the `Listbox.Button`. This `Listbox.Button` is already labelled by the
`Listbox.Label` if there is one.

This also means that we can safely drop the `id` of the label inside the
`aria-labelledby` from the `Listbox.Options`.

This wouldn't have worked if our `Listbox.Options` could be used in a
standalone way without the `Listbox.Button`.

At the end of the day the hierarchy looks like this:

- Options is labelled by the Button
   - Button is labelled by the Label
      - Label

Fixes: #2817
Copy link

vercel bot commented Nov 2, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
headlessui-react ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 2, 2023 3:34pm
headlessui-vue ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 2, 2023 3:34pm

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.

Listbox with label isn't read properly by VoiceOver
1 participant