Skip to content

Commit 25ae6b3

Browse files
committed
fix(VRadioGroup): emit the new value when reset
fixes #4752
1 parent 7abf1aa commit 25ae6b3

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

src/components/VInput/VInput.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export default {
9393
},
9494
set (val) {
9595
this.lazyValue = val
96-
this.$emit('input', val)
96+
this.$emit(this.$_modelEvent, val)
9797
}
9898
},
9999
isDirty () {
@@ -113,6 +113,12 @@ export default {
113113
}
114114
},
115115

116+
beforeCreate () {
117+
// v-radio-group needs to emit a different event
118+
// https://github.com/vuetifyjs/vuetify/issues/4752
119+
this.$_modelEvent = (this.$options.model && this.$options.model.event) || 'input'
120+
},
121+
116122
methods: {
117123
genContent () {
118124
return [

src/mixins/selectable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export default {
8080

8181
watch: {
8282
inputValue (val) {
83-
this.internalValue = val
83+
this.lazyValue = val
8484
}
8585
},
8686

test/unit/components/VRadioGroup/VRadioGroup.spec.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,4 +332,23 @@ test('VRadioGroup.vue', ({ mount }) => {
332332
radio.first('input').trigger('change')
333333
expect(onChange).not.toBeCalled()
334334
})
335+
336+
it('should reset', async () => {
337+
const wrapper = mount(VRadioGroup, {
338+
propsData: {
339+
value: '0'
340+
},
341+
slots: {
342+
default: [VRadio]
343+
}
344+
})
345+
const change = jest.fn()
346+
wrapper.vm.$on('change', change)
347+
348+
wrapper.vm.reset()
349+
await wrapper.vm.$nextTick()
350+
351+
expect(change).toHaveBeenCalledTimes(1)
352+
expect(change).toHaveBeenCalledWith(undefined)
353+
})
335354
})

0 commit comments

Comments
 (0)