You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CheckboxGroup: validationBehavior="aria" is ignored by its checkboxes since 1.18 #10856
Setting validationBehavior="aria" on a CheckboxGroup doesn't reach the checkboxes inside it. A required group with nothing checked still blocks a native form submit, as if it were native. It works in 1.17.0 and broke in 1.18.0, with #9877 (f23d22f).
🤔 Expected Behavior?
With validationBehavior="aria" on the group, the group is marked invalid through ARIA and the form still submits.
😯 Current Behavior
The checkbox input gets required, and form.checkValidity() returns false, so the browser blocks the submit. Setting validationBehavior="aria" on each Checkbox as well makes it behave.
💁 Possible Solution
This came in with #9877. useCheckboxAria in Checkbox.tsx now resolves validationBehavior to props ?? form ?? 'native' and passes it to useCheckboxGroupItem too. useCheckboxGroupItem only falls back to the group's setting when the checkbox's is undefined, and with the 'native' default it never is. Before that change, the default was only passed to useCheckbox for standalone checkboxes. Leaving the 'native' default out for checkboxes inside a group should fix it.
🔦 Context
validationBehavior="aria" is how a form library like react-hook-form keeps the browser out of validation. With a CheckboxGroup that setting is lost, so the browser blocks the submit before the library's handler runs. The workaround is to also set validationBehavior="aria" on every Checkbox in the group.
Click Submit with nothing checked. Expected: "submitted". Actual: Chrome shows "Please check this box if you want to proceed." and the form doesn't submit.
Same code on 1.17.0 submits. On 1.18.0 and later it doesn't (checked 1.18.0, 1.21.1 and 1.22.1).
Version
react-aria-components 1.22.1 (broken since 1.18.0; 1.17.0 works)
Activity
fix(react-aria-components): inherit CheckboxGroup validationBehavior (a…