mirror of https://github.com/ElemeFE/element
picker: fix clear value
parent
00e8c7454f
commit
07acf66a69
|
@ -406,7 +406,7 @@
|
|||
this.maxDate = null;
|
||||
this.leftDate = calcDefaultValue(this.defaultValue)[0];
|
||||
this.rightDate = nextMonth(this.leftDate);
|
||||
this.handleConfirm(false);
|
||||
this.$emit('pick', null);
|
||||
},
|
||||
|
||||
handleChangeRange(val) {
|
||||
|
|
|
@ -214,7 +214,7 @@
|
|||
|
||||
handleClear() {
|
||||
this.date = this.defaultValue ? new Date(this.defaultValue) : new Date();
|
||||
this.$emit('pick');
|
||||
this.$emit('pick', null);
|
||||
},
|
||||
|
||||
emit(value, ...args) {
|
||||
|
|
|
@ -150,7 +150,7 @@
|
|||
|
||||
methods: {
|
||||
handleClear() {
|
||||
this.$emit('pick', []);
|
||||
this.$emit('pick', null);
|
||||
},
|
||||
|
||||
handleCancel() {
|
||||
|
|
|
@ -90,7 +90,7 @@
|
|||
},
|
||||
|
||||
handleClear() {
|
||||
this.$emit('pick');
|
||||
this.$emit('pick', null);
|
||||
},
|
||||
|
||||
scrollToOption(selector = '.selected') {
|
||||
|
|
|
@ -101,13 +101,14 @@ describe('DatePicker', () => {
|
|||
setTimeout(_ => {
|
||||
const $el = vm.$refs.compo.picker.$el;
|
||||
$el.querySelector('td.available').click();
|
||||
vm.$nextTick(_ => {
|
||||
vm.$el.querySelector('.el-input__icon').click();
|
||||
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();
|
||||
}, DELAY);
|
||||
});
|
||||
}, DELAY);
|
||||
}, DELAY);
|
||||
});
|
||||
|
||||
|
@ -1175,6 +1176,28 @@ describe('DatePicker', () => {
|
|||
done();
|
||||
}, 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', () => {
|
||||
|
|
Loading…
Reference in New Issue