mirror of
https://github.com/tenrok/vue2-datepicker.git
synced 2026-06-24 12:40:35 +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) {
|
if (this.editable && this.userInput !== null) {
|
||||||
const calendar = this.$children[0]
|
const calendar = this.$children[0]
|
||||||
const checkDate = calendar.isDisabledTime
|
const checkDate = calendar.isDisabledTime
|
||||||
|
if (!value) {
|
||||||
|
this.clearDate()
|
||||||
|
return
|
||||||
|
}
|
||||||
if (this.range) {
|
if (this.range) {
|
||||||
const range = value.split(` ${this.rangeSeparator} `)
|
const range = value.split(` ${this.rangeSeparator} `)
|
||||||
if (range.length === 2) {
|
if (range.length === 2) {
|
||||||
|
|||||||
@@ -235,6 +235,25 @@ describe('datepicker', () => {
|
|||||||
expect(shortcuts.exists()).toBe(false)
|
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) => {
|
it('type input should be right', (done) => {
|
||||||
wrapper = mount(DatePicker, {
|
wrapper = mount(DatePicker, {
|
||||||
propsData: {
|
propsData: {
|
||||||
|
|||||||
Reference in New Issue
Block a user