vue-bulma / datepicker

Datepicker Component for Vue Bulma
MIT License
115 stars 56 forks source link

Can't delete a date once selected #76

Open sofuxro opened 6 years ago

sofuxro commented 6 years ago

I've tried this:

<datepicker :model="startAt" :config="{ wrap: true }">
    <a class="button" data-clear><i class="fa fa-close"></i></a>
</datepicker>

(it does remove it from the input but the date persists in the model => the user doesn't see a date anymore, but the code still has it)

I saw that flickr (the one implemented here) can delete dates with Backspace. On this datepicker I can't do that either.

Am I missing something ? how can I set my startAt to null or empty string

dgriego commented 6 years ago

I am also having this same issue,

I tried adding a click event in addition to the data-clear like so (primitive example):

<a class="button" data-clear @click="clearDate"><i class="fa fa-close"></i></a>

...
clearDate() {
  this.date = ''
}

this actually updated the data to the value I wanted, but visually it would clear and then the date would somehow reappear even though the data properties value was now an empty string. If you try this method you will have to click twice to remove it from the UI as well. Nevertheless, I would like to implement this in a cleaner way and using the default API that flatpickr offers.

jaybeecave commented 5 years ago

Agreed this is annoying but you can do something like

    clearDatePicker () {
      this.$emit('input', null)
      this.$nextTick(() => {
        this.$refs['field'].datepicker.clear()
      })
    },

I have the datepicker wrapped in my own control