blueprint
blueprint copied to clipboard
feat(SegmentedControl): a11y - set role to radiogroup
Improves a11y of new SegmentedControl item, giving it the radiogroup
role and also allowing it to be controlled with arrow keys.
- [X] Added Tests
Various open source UI toolkits have different approaches for Segmented Control a11y:
-
Primer explicitly advises against using
radiogroup
,tablist
, ortoolbar
ARIA roles -
MUI's Toggle Button Group uses
role="group"
-
Mantine UI uses
role="radiogroup"
Can you explain the motivations for your change and make an argument for setting the default as you've done in this PR?
I think a safer, better approach might be to add good documentation to the component docs suggesting that users should set their own ARIA role appropriately by specifying the role
attribute.
@adidahiya that is tricky. After reading through those, I agree my original choice of listbox
was incorrect.
It sounds like radiogroup
is the best option, I changed the code to that. Despite what that Primer link says, I see no evidence why it shouldn't be radiogroup
when that's exactly how it behaves.
If you would like me to add a role
prop-- role?="group" | "list" | "radiogroup"
-- and then we set the children roles and aria props based on that as well, I'm up for it. But IMO, I don't think anyone would complain about it being hard set to radiogroup
@adidahiya seems like this has gone stale? Please see my last comment.
@evansjohnson Done, added arrow key control and the proper tabIndex
setting! Tested, works great.