Skip to content

Commit

Permalink
refactor(Checkbox): check indeterminate state in click event handler (#…
Browse files Browse the repository at this point in the history
…682)

* fix(Checkbox): check indeterminate state in click event handler

* fix: update failing test
  • Loading branch information
DamianGlowala committed Feb 13, 2024
1 parent 7afe8c9 commit 6d8e21c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/radix-vue/src/Checkbox/Checkbox.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ describe('given checked value as "indeterminate"', async () => {

it('should still be clickable', async () => {
await wrapper.find('button').trigger('click')
expect(wrapper.find('button').attributes('data-state')).toBe('unchecked')
expect(wrapper.find('button').attributes('data-state')).toBe('checked')
})
})

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 @@ -90,7 +90,7 @@ provideCheckboxRootContext({
@keydown.enter.prevent="() => {
// According to WAI ARIA, Checkboxes don't activate on enter keypress
}"
@click="checked = !checked"
@click="checked = isIndeterminate(checked) ? true : !checked"
>
<slot />
</Primitive>
Expand Down

0 comments on commit 6d8e21c

Please sign in to comment.