Skip to content

Commit

Permalink
🚀 [FET-245] HdCheckbox shouldn't directly change the prop `indetermin…
Browse files Browse the repository at this point in the history
…ate`

🚀  [FET-245] HdCheckbox shouldn't directly change the prop `indeterminate`
  • Loading branch information
ilyasmez authored Apr 14, 2021
2 parents e1dee7b + f580a98 commit 69a2227
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/components/form/HdCheckbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
['checkbox--active']: isActive,
['checkbox--disabled']: disabled,
['checkbox--checked']: isChecked,
['checkbox--indeterminate']: indeterminate,
['checkbox--indeterminate']: boundIndeterminate,
['checkout--use-mouse']: isUsingMouse,
}"
:key="name+error+isChecked"
Expand Down Expand Up @@ -125,6 +125,7 @@ export default {
isActive: false,
isUsingMouse: false,
helper: null,
boundIndeterminate: this.indeterminate,
};
},
computed: {
Expand All @@ -140,7 +141,7 @@ export default {
},
},
statusIcon() {
if (this.indeterminate) return minusIcon;
if (this.boundIndeterminate) return minusIcon;
if (this.isChecked) return checkIcon;
return null;
},
Expand Down Expand Up @@ -175,10 +176,12 @@ export default {
},
watch: {
isChecked() {
// TODO: Don't mutate the prop
// https://homeday.atlassian.net/browse/FET-245
// eslint-disable-next-line vue/no-mutating-props
this.indeterminate = false;
if (this.boundIndeterminate) {
this.boundIndeterminate = false;
}
},
indeterminate(newIndeterminate) {
this.boundIndeterminate = newIndeterminate;
},
},
};
Expand Down

0 comments on commit 69a2227

Please sign in to comment.