diff --git a/packages/select/src/select.vue b/packages/select/src/select.vue index 31b54b15b..1e59138bf 100644 --- a/packages/select/src/select.vue +++ b/packages/select/src/select.vue @@ -339,7 +339,7 @@ this.cachedPlaceHolder = this.currentPlaceholder = val; }, - value(val) { + value(val, oldVal) { if (this.multiple) { this.resetInputHeight(); if (val.length > 0 || (this.$refs.input && this.query !== '')) { @@ -356,6 +356,9 @@ if (this.filterable && !this.multiple) { this.inputLength = 20; } + if (!valueEquals(val, oldVal)) { + this.dispatch('ElFormItem', 'el.form.change', val); + } }, visible(val) { @@ -503,7 +506,6 @@ emitChange(val) { if (!valueEquals(this.value, val)) { this.$emit('change', val); - this.dispatch('ElFormItem', 'el.form.change', val); } }, diff --git a/test/unit/specs/form.spec.js b/test/unit/specs/form.spec.js index 9315cddf6..1c503ace9 100644 --- a/test/unit/specs/form.spec.js +++ b/test/unit/specs/form.spec.js @@ -380,15 +380,19 @@ describe('Form', () => { expect(valid).to.false; setTimeout(_ => { expect(field.validateMessage).to.equal('请选择活动区域'); - // programatic modification of bound value does not triggers change validation + // programatic modification triggers change validation vm.form.region = 'shanghai'; setTimeout(_ => { - expect(field.validateMessage).to.equal('请选择活动区域'); - // user modification of bound value triggers change validation - vm.$refs.opt.$el.click(); + expect(field.validateMessage).to.equal(''); + vm.form.region = ''; setTimeout(_ => { - expect(field.validateMessage).to.equal(''); - done(); + expect(field.validateMessage).to.equal('请选择活动区域'); + // user modification of bound value triggers change validation + vm.$refs.opt.$el.click(); + setTimeout(_ => { + expect(field.validateMessage).to.equal(''); + done(); + }, 100); }, 100); }, 100); }, 100);