diff --git a/components/radio/__tests__/group.test.js b/components/radio/__tests__/group.test.js index fa49106268..5df6acb05c 100644 --- a/components/radio/__tests__/group.test.js +++ b/components/radio/__tests__/group.test.js @@ -230,4 +230,41 @@ describe('Radio', () => { }); expect(wrapper.html()).toMatchSnapshot(); }); + + it('when onChange do not change the value, change event can be also triggered.', async () => { + const onChange = jest.fn(); + const onChangeRadioGroup = () => { + onChange(); + wrapper.setProps({ value: 'A' }); + }; + + const wrapper = mount( + { + props: ['value'], + render() { + const value = this.value || 'A'; + return ( + + A + B + C + + ); + }, + }, + { sync: false }, + ); + + const radios = wrapper.findAll('input'); + + await asyncExpect(() => { + radios.at(1).trigger('click'); + expect(onChange.mock.calls.length).toBe(1); + }); + + await asyncExpect(() => { + radios.at(1).trigger('click'); + expect(onChange.mock.calls.length).toBe(2); + }); + }); }); diff --git a/components/vc-checkbox/src/Checkbox.jsx b/components/vc-checkbox/src/Checkbox.jsx index adb6926515..475871373b 100644 --- a/components/vc-checkbox/src/Checkbox.jsx +++ b/components/vc-checkbox/src/Checkbox.jsx @@ -92,6 +92,10 @@ export default { nativeEvent: e, }); this.eventShiftKey = false; + // fix https://github.com/vueComponent/ant-design-vue/issues/3047 + if ('checked' in props) { + this.$refs.input.checked = props.checked; + } }, onClick(e) { this.__emit('click', e);