mirror of https://github.com/ElemeFE/element
DatePicker: fix change event on clear (#9986)
parent
62b0e2ace9
commit
cacb0aeaec
|
@ -617,6 +617,7 @@ export default {
|
||||||
handleClickIcon(event) {
|
handleClickIcon(event) {
|
||||||
if (this.readonly || this.pickerDisabled) return;
|
if (this.readonly || this.pickerDisabled) return;
|
||||||
if (this.showClose) {
|
if (this.showClose) {
|
||||||
|
this.valueOnOpen = this.value;
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
this.emitInput(null);
|
this.emitInput(null);
|
||||||
this.emitChange(null);
|
this.emitChange(null);
|
||||||
|
|
|
@ -233,6 +233,34 @@ describe('DatePicker', () => {
|
||||||
}, DELAY);
|
}, DELAY);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('change event: when clear(), without opening picker', done => {
|
||||||
|
vm = createVue({
|
||||||
|
template: `
|
||||||
|
<el-date-picker
|
||||||
|
ref="compo"
|
||||||
|
v-model="value"
|
||||||
|
/>`,
|
||||||
|
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', () => {
|
describe('input event', () => {
|
||||||
// mimic standard <select>'s behavior
|
// mimic standard <select>'s behavior
|
||||||
// emit input if and only if value changes
|
// emit input if and only if value changes
|
||||||
|
|
Loading…
Reference in New Issue