RadioGroup isn't keyboard accessible when RadioGroup.Item is disabled and selected #1575
Replies: 3 comments
-
Why would a disabled item ever be selected? I guess my question is how does it even get into that state? |
Beta Was this translation helpful? Give feedback.
-
It's a reasonable question! I can see a use-case in a form with interdependent fields, where a new selection makes an existing selection invalid. That said, I only discovered this while testing styling in Storybook, which is why I left it tagged as "annoyance". Also, after some more research, this seems to be an unresolved problem for native radio groups in most browsers? |
Beta Was this translation helpful? Give feedback.
-
Yeah the issue stems from the fact that a disabled item is selected. Since we use the roving tabindex/focus pattern here, the selected item gets This is technically valid HTML, but it's an anti-pattern. A selected item should never be disabled - if an option becomes unavailable, it should first be deselected or replaced with a new valid selection. We’ll consider adding a dev-time warning to catch this specific scenario, but at the library level it feels wrong to do anything further, as the options would be to forcefully deselect which could also be undesired in certain circumstances. However, this does bring up something we probably should do, which is provide an option to make the radio group |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the bug
The entire RadioGroup is removed from the tab order. It should remain available, allowing keyboard users to select another option.
Using a mouse, it is possible to select a different option, restoring normal function.
Reproduction
https://stackblitz.com/edit/oohjsspd?file=src%2Froutes%2F%2Bpage.svelte
Logs
System Info
Severity
annoyance
Beta Was this translation helpful? Give feedback.
All reactions