diff --git a/packages/date-picker/src/picker.vue b/packages/date-picker/src/picker.vue index 261f2f634..95f70a7d6 100644 --- a/packages/date-picker/src/picker.vue +++ b/packages/date-picker/src/picker.vue @@ -617,6 +617,7 @@ export default { handleClickIcon(event) { if (this.readonly || this.pickerDisabled) return; if (this.showClose) { + this.valueOnOpen = this.value; event.stopPropagation(); this.emitInput(null); this.emitChange(null); diff --git a/test/unit/specs/date-picker.spec.js b/test/unit/specs/date-picker.spec.js index d36c06518..b728125d3 100644 --- a/test/unit/specs/date-picker.spec.js +++ b/test/unit/specs/date-picker.spec.js @@ -233,6 +233,34 @@ describe('DatePicker', () => { }, DELAY); }); + it('change event: when clear(), without opening picker', done => { + vm = createVue({ + template: ` + `, + data() { + return { + value: new Date() + }; + } + }, true); + + const spy = sinon.spy(); + vm.$refs.compo.$on('change', spy); + + setTimeout(_ => { + vm.$refs.compo.showClose = true; + vm.$refs.compo.handleClickIcon({ stopPropagation: () => null }); + setTimeout(_ => { + expect(spy.calledOnce).to.equal(true); + expect(spy.calledWith(null)).to.equal(true); + done(); + }, DELAY); + }, DELAY); + }); + describe('input event', () => { // mimic standard