darrenfang/vuetify-datetime-picker

Setting datetime model to null does not reset text field.

Opened this issue · 3 comments

Changing init method to this solved the problem.

init() {
  if (!this.datetime) {
    this.resetPicker()
    this.date = DEFAULT_DATE
    this.time = DEFAULT_TIME
    return
  }
  let initDateTime
  if (this.datetime instanceof Date) {
    initDateTime = this.datetime
  } else if (typeof this.datetime === 'string' || this.datetime instanceof String) {
    // see https://stackoverflow.com/a/9436948
    initDateTime = parse(this.datetime, this.dateTimeFormat, new Date())
  }
  this.date = format(initDateTime, DEFAULT_DATE_FORMAT)
  this.time = format(initDateTime, DEFAULT_TIME_FORMAT)
},

Hi,

Nice component for Date Time, I am suffering from this exact same problem.

Any plans to push this update anytime soon to npm repo ?

I am running 2.1.1 and it is not in there ...

Thanks

me too - any suggested idea's on this?

I was able to workaround this creating a ref to the element and calling clearHandler() method when I want the field to be reseted

<v-datetime-picker v-model="myDateTime" ref="myInput" />
//...
watch: {
   myDateTime (val) {
      if (!val) {
         this.$refs.myInput.clearHandler()
      }
   }
}
//...

I know this isn't the ideal solution, but I'm using this when a fix is not provided