Permalink
Browse files

fix(radios checkboxes): Parent group should emit change event (#1071)

* Update form-radio.vue

* [form-radio-group] Child is responsible for emitting change event on radio-group

* [form-checkbox] emit change event on parent if inside form-checkbox-group

* [form-checkbox-group] Children are responsible for emitting change event on checkbox-group

* Update form-radio.vue
  • Loading branch information...
tmorehouse committed Sep 16, 2017
1 parent c267afa commit ac7c506ff74e1b94120c0ec2cfbfb953feeec315
@@ -6,7 +6,6 @@
:data-toggle="buttons ? 'buttons' : null"
:aria-required="required ? 'true' : null"
:aria-invalid="computedAriaInvalid"
@change="$emit('change', localChecked)"
>
<slot name="first"></slot>
<!-- b-form-checkbox will grab v-model (checked) from b-form-checkboxes -->
@@ -110,6 +110,10 @@
// And we only emit the value of this checkbox
if (this.is_Child || isArray(this.computedLocalChecked)) {
this.$emit('change', checked ? this.value : null);
if (this.is_Child) {
// If we are a child of form-checkbbox-group, emit change on parent
this.$parent.$emit('change', this.computedLocalChecked);
}
} else {
// Single radio mode supports unchecked value
this.$emit('change', checked ? this.value : this.uncheckedValue)
@@ -6,7 +6,6 @@
:data-toggle="buttons ? 'buttons' : null"
:aria-required="required ? 'true' : null"
:aria-invalid="computedAriaInvalid"
@change="$emit('change', localChecked)"
>
<slot name="first"></slot>
<!-- b-form-radio will grab v-model (checked) from b-form-radio-group -->
@@ -74,6 +74,10 @@
handleChange({ target: { checked } }) {
// Change is only emitted on user interaction
this.$emit('change', checked ? this.value : null);
// If this is a child of form-radio-group, we emit a change event on it as well
if (this.is_Child) {
this.$parent.$emit('change', this.computedLocalChecked);
}
}
}
};

0 comments on commit ac7c506

Please sign in to comment.