source icon indicating copy to clipboard operation
source copied to clipboard

Checkbox/Radio enable them to be required

Open liywjl opened this issue 5 years ago • 3 comments

Is your feature request related to a problem? Please describe. Unable to require a group of radio or checkboxes to be selected on a form

Describe the solution you'd like Support optional prop for RadioGroup and CheckboxGroup

liywjl avatar Dec 14 '20 16:12 liywjl

Thanks @liywjl. For RadioGroup, we can apply the required attribute to each radio element. We can add a radiogroup role to the fieldset and apply the aria-required attribute if the optional prop is not specified.

Have you had instances when it has been necessary for CheckboxGroup to be required i.e. at least one checkbox must be selected from a group? I can imagine instances where a single checkbox must be selected, for instance to indicate that a user accepts some T&Cs.

SiAdcock avatar Dec 29 '20 11:12 SiAdcock

Yes I think supporting required for both RadioGroup and CheckboxGroup would be super useful. Currently we have an issue with not being able to enfore required in checkbox on a callout:

https://www.theguardian.com/politics/2020/may/05/boris-johnson-boasted-of-shaking-hands-on-day-sage-warned-not-to?dcr

I think as well for what you metioned a T&C checkbox would be super useful. Another area where this would be useful would be for the Quiz Atoms that we are looking at supporting.

liywjl avatar Dec 29 '20 11:12 liywjl

Great, thanks so much for the extra context @liywjl, we are happy to support this feature. It would be great for consistency too. Would you be up for raising a PR?

SiAdcock avatar Dec 31 '20 10:12 SiAdcock