mirror of
https://github.com/tenrok/vue2-datepicker.git
synced 2026-06-14 00:42:26 +03:00
fix: when clear input(not use clear button) the date value not changed
This commit is contained in:
@@ -472,6 +472,10 @@ export default {
|
||||
if (this.editable && this.userInput !== null) {
|
||||
const calendar = this.$children[0]
|
||||
const checkDate = calendar.isDisabledTime
|
||||
if (!value) {
|
||||
this.clearDate()
|
||||
return
|
||||
}
|
||||
if (this.range) {
|
||||
const range = value.split(` ${this.rangeSeparator} `)
|
||||
if (range.length === 2) {
|
||||
|
||||
@@ -235,6 +235,25 @@ describe('datepicker', () => {
|
||||
expect(shortcuts.exists()).toBe(false)
|
||||
})
|
||||
|
||||
it('clear the value will set the value null', (done) => {
|
||||
wrapper = mount(DatePicker, {
|
||||
propsData: {
|
||||
format: 'YYYY-MM-DD',
|
||||
value: '2018-09-10'
|
||||
},
|
||||
sync: false
|
||||
})
|
||||
const input = wrapper.find('input')
|
||||
input.setValue('')
|
||||
input.trigger('input')
|
||||
input.trigger('change')
|
||||
Vue.nextTick(() => {
|
||||
const emitted = wrapper.emitted()
|
||||
expect(emitted.input).toEqual([[null]])
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('type input should be right', (done) => {
|
||||
wrapper = mount(DatePicker, {
|
||||
propsData: {
|
||||
|
||||
Reference in New Issue
Block a user