mirror of https://github.com/ElemeFE/element
date-picker: fix form change validation (#12328)
parent
9303122f7f
commit
9f80cf91da
|
@ -428,6 +428,11 @@ export default {
|
||||||
if (this.picker) {
|
if (this.picker) {
|
||||||
this.picker.defaultValue = val;
|
this.picker.defaultValue = val;
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
value(val, oldVal) {
|
||||||
|
if (!valueEquals(val, oldVal)) {
|
||||||
|
this.dispatch('ElFormItem', 'el.form.change', val);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -894,7 +899,6 @@ export default {
|
||||||
// determine user real change only
|
// determine user real change only
|
||||||
if (!valueEquals(val, this.valueOnOpen)) {
|
if (!valueEquals(val, this.valueOnOpen)) {
|
||||||
this.$emit('change', val);
|
this.$emit('change', val);
|
||||||
this.dispatch('ElFormItem', 'el.form.change', val);
|
|
||||||
this.valueOnOpen = val;
|
this.valueOnOpen = val;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -483,11 +483,11 @@ describe('Form', () => {
|
||||||
expect(valid).to.not.true;
|
expect(valid).to.not.true;
|
||||||
setTimeout(_ => {
|
setTimeout(_ => {
|
||||||
expect(field.validateMessage).to.equal('请选择日期');
|
expect(field.validateMessage).to.equal('请选择日期');
|
||||||
// programatic modification does not trigger change
|
// programatic modification triggers change validation
|
||||||
vm.value = new Date();
|
vm.form.date = new Date();
|
||||||
setTimeout(_ => {
|
setTimeout(_ => {
|
||||||
expect(field.validateMessage).to.equal('请选择日期');
|
expect(field.validateMessage).to.equal('');
|
||||||
vm.value = '';
|
vm.form.date = '';
|
||||||
// user modification triggers change
|
// user modification triggers change
|
||||||
const input = vm.$refs.picker.$el.querySelector('input');
|
const input = vm.$refs.picker.$el.querySelector('input');
|
||||||
input.blur();
|
input.blur();
|
||||||
|
|
Loading…
Reference in New Issue