Skip to content

Commit

Permalink
fix(Checkbox): set aria-required to required prop value (#1596)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmairoldi authored Jan 31, 2025
1 parent 586c25a commit 14da5f1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions packages/radix-vue/src/Checkbox/Checkbox.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,18 @@ describe('given a disabled Checkbox', () => {
})
})

describe('given a required Checkbox', () => {
const wrapper = mount({
components: { Checkbox },
template: '<form><Checkbox required /></form>',
})

it('should have [aria-required] of "true"', () => {
expect(wrapper.find('button').attributes('aria-required')).toEqual('true')
expect(wrapper.find('[type="checkbox"]').attributes('required')).toBeDefined()
})
})

describe('given checked value as "indeterminate"', async () => {
const wrapper = mount(Checkbox, { props: { checked: 'indeterminate' } })

Expand Down
2 changes: 1 addition & 1 deletion packages/radix-vue/src/Checkbox/CheckboxRoot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ provideCheckboxRootContext({
:as="as"
:type="as === 'button' ? 'button' : undefined"
:aria-checked="isIndeterminate(checked) ? 'mixed' : checked"
:aria-required="false"
:aria-required="props.required"
:aria-label="$attrs['aria-label'] || ariaLabel"
:data-state="getState(checked)"
:data-disabled="disabled ? '' : undefined"
Expand Down

0 comments on commit 14da5f1

Please sign in to comment.