Commit 0ed8d186 authored by Jiewei Qian's avatar Jiewei Qian Committed by hetech

Select: fix form change validation (#11672)

parent 1f24f2ab
...@@ -339,7 +339,7 @@ ...@@ -339,7 +339,7 @@
this.cachedPlaceHolder = this.currentPlaceholder = val; this.cachedPlaceHolder = this.currentPlaceholder = val;
}, },
value(val) { value(val, oldVal) {
if (this.multiple) { if (this.multiple) {
this.resetInputHeight(); this.resetInputHeight();
if (val.length > 0 || (this.$refs.input && this.query !== '')) { if (val.length > 0 || (this.$refs.input && this.query !== '')) {
...@@ -356,6 +356,9 @@ ...@@ -356,6 +356,9 @@
if (this.filterable && !this.multiple) { if (this.filterable && !this.multiple) {
this.inputLength = 20; this.inputLength = 20;
} }
if (!valueEquals(val, oldVal)) {
this.dispatch('ElFormItem', 'el.form.change', val);
}
}, },
visible(val) { visible(val) {
...@@ -503,7 +506,6 @@ ...@@ -503,7 +506,6 @@
emitChange(val) { emitChange(val) {
if (!valueEquals(this.value, val)) { if (!valueEquals(this.value, val)) {
this.$emit('change', val); this.$emit('change', val);
this.dispatch('ElFormItem', 'el.form.change', val);
} }
}, },
......
...@@ -380,8 +380,11 @@ describe('Form', () => { ...@@ -380,8 +380,11 @@ describe('Form', () => {
expect(valid).to.false; expect(valid).to.false;
setTimeout(_ => { setTimeout(_ => {
expect(field.validateMessage).to.equal('请选择活动区域'); expect(field.validateMessage).to.equal('请选择活动区域');
// programatic modification of bound value does not triggers change validation // programatic modification triggers change validation
vm.form.region = 'shanghai'; vm.form.region = 'shanghai';
setTimeout(_ => {
expect(field.validateMessage).to.equal('');
vm.form.region = '';
setTimeout(_ => { setTimeout(_ => {
expect(field.validateMessage).to.equal('请选择活动区域'); expect(field.validateMessage).to.equal('请选择活动区域');
// user modification of bound value triggers change validation // user modification of bound value triggers change validation
...@@ -392,6 +395,7 @@ describe('Form', () => { ...@@ -392,6 +395,7 @@ describe('Form', () => {
}, 100); }, 100);
}, 100); }, 100);
}, 100); }, 100);
}, 100);
}); });
}); });
it('datepicker', done => { it('datepicker', done => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment