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

RadioGroup is unreachable with keyboard if none of the options are checked #378

Closed
BjornDCode opened this issue Apr 16, 2021 · 3 comments
Closed

Comments

@BjornDCode
Copy link

BjornDCode commented Apr 16, 2021

What package within Headless UI are you using?

@headlessui/react

What version of that package are you using?

v1.0.0

What browser are you using?

Chrome

Reproduction repository

https://codesandbox.io/s/elated-yonath-thyp7?file=/src/App.js

Description

Because all RadioGroup.Option elements have tabindex=-1 unless they are checked it's not currently possible to reach a RadioGroup by keyboard if the default value of the RadioGroup is null. Normal browser behaviour is to focus the first option if tabbing forward and focus the last element if tabbing backwards

@RobinMalfait
Copy link
Member

Hey! Thank you for your bug report!
Much appreciated! 🙏

The issue you are seeing is because you are using null as the default value. This can technically be a valid option of your radio items. Here is a small React application where we can showcase that: https://codesandbox.io/s/gifted-firefly-50qwq?file=/src/App.js

Here is a small React application that showcases that null could be a value when using Headless UI: https://codesandbox.io/s/boring-oskar-260ts

To fix it in your case, I would recommend you to change your null to undefined, which works as expected: https://codesandbox.io/s/quirky-bose-q5p2r?file=/src/App.js

If you have any more questions, please let me know!

@RobinMalfait
Copy link
Member

But you are right that this feels incorrect. In fact, not being able to tab at all is a bug, so will fix that and will get back to you!

RobinMalfait added a commit that referenced this issue Apr 19, 2021
Also did some general cleanup which in turn fixed an issue where the
RadioGroup is unreachable when a value is used that doesn't exist in the
list of options.

Fixes: #378
RobinMalfait added a commit that referenced this issue Apr 19, 2021
Also did some general cleanup which in turn fixed an issue where the
RadioGroup is unreachable when a value is used that doesn't exist in the
list of options.

Fixes: #378
RobinMalfait added a commit that referenced this issue Apr 19, 2021
* add `disabled` prop to RadioGroup and RadioGroup Option

Also did some general cleanup which in turn fixed an issue where the
RadioGroup is unreachable when a value is used that doesn't exist in the
list of options.

Fixes: #378

* update changelog
@RobinMalfait
Copy link
Member

Hey! Thank you for your bug report!
Much appreciated! 🙏

This should be fixed, and will be available in the next release.
You can already try it using npm install @headlessui/react@dev or yarn add @headlessui/react@dev.

Here is your reproduction CodeSandbox with the newest dev version applied: https://codesandbox.io/s/inspiring-volhard-5uljb

RobinMalfait added a commit that referenced this issue Apr 19, 2021
* add `disabled` prop to RadioGroup and RadioGroup Option

Also did some general cleanup which in turn fixed an issue where the
RadioGroup is unreachable when a value is used that doesn't exist in the
list of options.

Fixes: #378

* update changelog
RobinMalfait added a commit that referenced this issue Apr 20, 2021
* add `disabled` prop to RadioGroup and RadioGroup Option

Also did some general cleanup which in turn fixed an issue where the
RadioGroup is unreachable when a value is used that doesn't exist in the
list of options.

Fixes: #378

* update changelog
RobinMalfait added a commit that referenced this issue Apr 26, 2021
* Fixed typos (#350)

* chore: Fix typo in render.ts (#347)

* Better vue link (#353)

* Better vue link

* add better React link

Co-authored-by: Robin Malfait <malfait.robin@gmail.com>

* Enable NoScroll feature for the initial useFocusTrap hook (#356)

* enable NoScroll feature for the initial useFocusTrap hook

Once you are using Tab and Shift+Tab it does the scrolling.

Fixes: #345

* update changelog

* Revert "Enable NoScroll feature for the initial useFocusTrap hook (#356)"

This reverts commit 19590b0.

Solution is not 100% correct, so will revert for now!

* Improve search (#385)

* make search case insensitive for the listbox

* make search case insensitive for the menu

* update changelog

* add `disabled` prop to RadioGroup and RadioGroup Option (#401)

* add `disabled` prop to RadioGroup and RadioGroup Option

Also did some general cleanup which in turn fixed an issue where the
RadioGroup is unreachable when a value is used that doesn't exist in the
list of options.

Fixes: #378

* update changelog

* Fix type of `RadioGroupOption` (#400)

Match RadioGroupOption value types to match modelValue allowed types for RadioGroup

* update changelog

* fix typo's

* chore(CI): update main workflow (#395)

* chore(CI): update main workflow

* Update main.yml

* fix dialog event propagation (#422)

* re-export the `screen` utility for quick debugging purposes

* stop event propagation when clicking inside a Dialog

Fixes: #414

* improve dialog escape (#430)

* Make sure that `Escape` only closes the top most Dialog

* update changelog

* add defaultOpen prop to Disclosure component (#447)

* add defaultOpen prop to Disclosure component

* update changelog

Co-authored-by: Shuvro Roy <shuvro.roy@northsouth.edu>
Co-authored-by: Alex Nault <nault.alex@gmail.com>
Co-authored-by: Eugene Kopich <github@web2033.com>
Co-authored-by: Nathan Shoemark <n.shoemark@gmail.com>
Co-authored-by: Michaël De Boey <info@michaeldeboey.be>
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

No branches or pull requests

2 participants