mirror of https://github.com/ElemeFE/element
picker: fix clear value
parent
00e8c7454f
commit
07acf66a69
|
@ -406,7 +406,7 @@
|
||||||
this.maxDate = null;
|
this.maxDate = null;
|
||||||
this.leftDate = calcDefaultValue(this.defaultValue)[0];
|
this.leftDate = calcDefaultValue(this.defaultValue)[0];
|
||||||
this.rightDate = nextMonth(this.leftDate);
|
this.rightDate = nextMonth(this.leftDate);
|
||||||
this.handleConfirm(false);
|
this.$emit('pick', null);
|
||||||
},
|
},
|
||||||
|
|
||||||
handleChangeRange(val) {
|
handleChangeRange(val) {
|
||||||
|
|
|
@ -214,7 +214,7 @@
|
||||||
|
|
||||||
handleClear() {
|
handleClear() {
|
||||||
this.date = this.defaultValue ? new Date(this.defaultValue) : new Date();
|
this.date = this.defaultValue ? new Date(this.defaultValue) : new Date();
|
||||||
this.$emit('pick');
|
this.$emit('pick', null);
|
||||||
},
|
},
|
||||||
|
|
||||||
emit(value, ...args) {
|
emit(value, ...args) {
|
||||||
|
|
|
@ -150,7 +150,7 @@
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
handleClear() {
|
handleClear() {
|
||||||
this.$emit('pick', []);
|
this.$emit('pick', null);
|
||||||
},
|
},
|
||||||
|
|
||||||
handleCancel() {
|
handleCancel() {
|
||||||
|
|
|
@ -90,7 +90,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
handleClear() {
|
handleClear() {
|
||||||
this.$emit('pick');
|
this.$emit('pick', null);
|
||||||
},
|
},
|
||||||
|
|
||||||
scrollToOption(selector = '.selected') {
|
scrollToOption(selector = '.selected') {
|
||||||
|
|
|
@ -101,13 +101,14 @@ describe('DatePicker', () => {
|
||||||
setTimeout(_ => {
|
setTimeout(_ => {
|
||||||
const $el = vm.$refs.compo.picker.$el;
|
const $el = vm.$refs.compo.picker.$el;
|
||||||
$el.querySelector('td.available').click();
|
$el.querySelector('td.available').click();
|
||||||
vm.$nextTick(_ => {
|
|
||||||
vm.$el.querySelector('.el-input__icon').click();
|
|
||||||
setTimeout(_ => {
|
setTimeout(_ => {
|
||||||
expect(vm.value).to.empty;
|
vm.$refs.compo.showClose = true;
|
||||||
|
vm.$refs.compo.handleClickIcon({ stopPropagation: () => null });
|
||||||
|
setTimeout(_ => {
|
||||||
|
expect(vm.value).to.equal(null);
|
||||||
done();
|
done();
|
||||||
}, DELAY);
|
}, DELAY);
|
||||||
});
|
}, DELAY);
|
||||||
}, DELAY);
|
}, DELAY);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1175,6 +1176,28 @@ describe('DatePicker', () => {
|
||||||
done();
|
done();
|
||||||
}, DELAY);
|
}, DELAY);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('clear value', done => {
|
||||||
|
vm = createVue({
|
||||||
|
template: '<el-date-picker type="daterange" v-model="value" ref="compo" />',
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
value: [new Date(2000, 9, 1), new Date(2000, 9, 2)]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}, true);
|
||||||
|
|
||||||
|
vm.$el.querySelector('input').focus();
|
||||||
|
|
||||||
|
setTimeout(_ => {
|
||||||
|
vm.$refs.compo.showClose = true;
|
||||||
|
vm.$refs.compo.handleClickIcon({ stopPropagation: () => null });
|
||||||
|
setTimeout(_ => {
|
||||||
|
expect(vm.value).to.equal(null);
|
||||||
|
done();
|
||||||
|
}, DELAY);
|
||||||
|
}, DELAY);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('type:datetimerange', () => {
|
describe('type:datetimerange', () => {
|
||||||
|
|
Loading…
Reference in New Issue