Skip to content

Commit

Permalink
fix(NcCheckboxRadioSwitch): Fix invalid indeterminate checkbox semantics
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Ng <[email protected]>
  • Loading branch information
Pytal committed Jan 19, 2024
1 parent 1ad3480 commit 383dfa0
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions src/components/NcCheckboxRadioSwitch/NcCheckboxRadioSwitch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ export default {
['checkbox-radio-switch-' + type]: type,
'checkbox-radio-switch--checked': isChecked,
'checkbox-radio-switch--disabled': disabled,
'checkbox-radio-switch--indeterminate': indeterminate,
'checkbox-radio-switch--indeterminate': hasIndeterminate ? indeterminate : false,
'checkbox-radio-switch--button-variant': buttonVariant,
'checkbox-radio-switch--button-variant-v-grouped': buttonVariant && buttonVariantGrouped === 'vertical',
'checkbox-radio-switch--button-variant-h-grouped': buttonVariant && buttonVariantGrouped === 'horizontal',
Expand All @@ -283,14 +283,17 @@ export default {
:disabled="disabled"
:type="inputType"
:value="value"
v-bind="inputProps"
:checked="isChecked"
:indeterminate.prop="hasIndeterminate ? indeterminate : null"
:required="required"
:name="name"
v-on="listeners">
<NcCheckboxContent :id="id"
class="checkbox-radio-switch__content"
icon-class="checkbox-radio-switch__icon"
text-class="checkbox-radio-switch__text"
:type="type"
:indeterminate="indeterminate"
:indeterminate="hasIndeterminate ? indeterminate : false"
:button-variant="buttonVariant"
:is-checked="isChecked"
:loading="loading"
Expand Down Expand Up @@ -472,18 +475,6 @@ export default {
return 'span'
},
inputProps() {
if (this.isButtonType) {
return null
}
return {
checked: this.isChecked,
indeterminate: this.indeterminate,
required: this.required,
name: this.name,
}
},
listeners() {
if (this.isButtonType) {
return {
Expand Down Expand Up @@ -552,6 +543,13 @@ export default {
}
return this.checked === true
},
hasIndeterminate() {
return [
TYPE_CHECKBOX,
TYPE_RADIO,
].includes(this.inputType)
},
},
mounted() {
Expand Down

0 comments on commit 383dfa0

Please sign in to comment.