@@ -31,11 +31,9 @@ export const BFormRadio = /*#__PURE__*/ Vue.extend({
31
31
}
32
32
} ,
33
33
computed : {
34
- // Radio Groups can only have a single value, so determining if checked is simple
35
34
isChecked ( ) {
36
35
return looseEqual ( this . value , this . computedLocalChecked )
37
36
} ,
38
- // Flags for form-radio-check mixin
39
37
isRadio ( ) {
40
38
return true
41
39
} ,
@@ -44,21 +42,30 @@ export const BFormRadio = /*#__PURE__*/ Vue.extend({
44
42
}
45
43
} ,
46
44
watch : {
47
- // Radio Groups can only have a single value, so our watchers are simple
48
- computedLocalChecked ( ) {
49
- this . $emit ( 'input' , this . computedLocalChecked )
45
+ computedLocalChecked ( newValue , oldValue ) {
46
+ if ( ! looseEqual ( newValue , oldValue ) ) {
47
+ this . $emit ( 'input' , newValue )
48
+ }
50
49
}
51
50
} ,
52
51
methods : {
53
52
handleChange ( { target : { checked } } ) {
54
- const value = this . value
53
+ const { value } = this
54
+ const localChecked = checked ? value : null
55
+
55
56
this . computedLocalChecked = value
56
- // Change is only emitted on user interaction
57
- this . $emit ( 'change' , checked ? value : null )
58
- // If this is a child of form-radio-group, we emit a change event on it as well
59
- if ( this . isGroup ) {
60
- this . bvGroup . $emit ( 'change' , checked ? value : null )
61
- }
57
+
58
+ // Fire events in a `$nextTick()` to ensure the `v-model` is updated
59
+ this . $nextTick ( ( ) => {
60
+ // Change is only emitted on user interaction
61
+ this . $emit ( 'change' , localChecked )
62
+
63
+ // If this is a child of `<form-radio-group>`,
64
+ // we emit a change event on it as well
65
+ if ( this . isGroup ) {
66
+ this . bvGroup . $emit ( 'change' , localChecked )
67
+ }
68
+ } )
62
69
}
63
70
}
64
71
} )
0 commit comments