picker: fix clear value

pull/7746/head
wacky6.AriesMBP 2017-10-26 15:20:59 +11:00 committed by 杨奕
parent 00e8c7454f
commit 07acf66a69
5 changed files with 31 additions and 8 deletions

View File

@ -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) {

View File

@ -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) {

View File

@ -150,7 +150,7 @@
methods: {
handleClear() {
this.$emit('pick', []);
this.$emit('pick', null);
},
handleCancel() {

View File

@ -90,7 +90,7 @@
},
handleClear() {
this.$emit('pick');
this.$emit('pick', null);
},
scrollToOption(selector = '.selected') {

View File

@ -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', () => {