fix(RadioGroup): disabled prop not work (#4242)

This commit is contained in:
neverland 2019-08-26 16:31:59 +08:00 committed by GitHub
parent f172842c02
commit 2489ba2b79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 1 deletions

View File

@ -52,7 +52,7 @@ export const CheckboxMixin = ({ parent, bem, role }) => ({
const { target } = event;
const labelClicked = label && (label === target || label.contains(target));
if (!this.disabled && !(labelClicked && this.labelDisabled)) {
if (!this.isDisabled && !(labelClicked && this.labelDisabled)) {
this.toggle();
}

View File

@ -43,3 +43,34 @@ test('radio-group change', () => {
labels.at(3).trigger('click');
expect(wrapper.vm.result).toEqual('b');
});
test('radio group disabled', () => {
const wrapper = mount({
template: `
<radio-group v-model="result" disabled @change="$emit('change', $event)">
<radio
v-for="item in list"
:key="item"
:name="item"
>
label
</radio>
</radio-group>
`,
components: {
Radio,
RadioGroup
},
data() {
return {
result: 'a',
list: ['a', 'b', 'c', 'd']
};
}
});
const icons = wrapper.findAll('.van-radio__icon');
icons.at(2).trigger('click');
expect(wrapper.emitted('change')).toBeFalsy();
});