Skip to content

Commit 14da5f1

Browse files
authored
fix(Checkbox): set aria-required to required prop value (#1596)
1 parent 586c25a commit 14da5f1

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

packages/radix-vue/src/Checkbox/Checkbox.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,18 @@ describe('given a disabled Checkbox', () => {
8080
})
8181
})
8282

83+
describe('given a required Checkbox', () => {
84+
const wrapper = mount({
85+
components: { Checkbox },
86+
template: '<form><Checkbox required /></form>',
87+
})
88+
89+
it('should have [aria-required] of "true"', () => {
90+
expect(wrapper.find('button').attributes('aria-required')).toEqual('true')
91+
expect(wrapper.find('[type="checkbox"]').attributes('required')).toBeDefined()
92+
})
93+
})
94+
8395
describe('given checked value as "indeterminate"', async () => {
8496
const wrapper = mount(Checkbox, { props: { checked: 'indeterminate' } })
8597

packages/radix-vue/src/Checkbox/CheckboxRoot.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ provideCheckboxRootContext({
9191
:as="as"
9292
:type="as === 'button' ? 'button' : undefined"
9393
:aria-checked="isIndeterminate(checked) ? 'mixed' : checked"
94-
:aria-required="false"
94+
:aria-required="props.required"
9595
:aria-label="$attrs['aria-label'] || ariaLabel"
9696
:data-state="getState(checked)"
9797
:data-disabled="disabled ? '' : undefined"

0 commit comments

Comments
 (0)