Skip to content

Commit

Permalink
fix: when clear input(not use clear button) the date value not changed
Browse files Browse the repository at this point in the history
  • Loading branch information
mengxiong10 committed Dec 19, 2018
1 parent 454417e commit 39d2c40
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
19 changes: 19 additions & 0 deletions test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit 39d2c40

Please sign in to comment.