nathanreyes / v-calendar

An elegant calendar and datepicker plugin for Vue.
https://vcalendar.io
MIT License
4.41k stars 864 forks source link

Move Method with DatePicker and Slot #705

Closed laferte-tech closed 3 years ago

laferte-tech commented 4 years ago

Hi, I have updated to the new version and i have a trouble to use the move method. Not sure it's a bug but when i use DatePicker without this slot (the one you gave on your doc):

  <template v-slot="{ inputValue, inputEvents }">
    <input
      class="bg-white border px-2 py-1 rounded"
      :value="inputValue"
      v-on="inputEvents"
    />
  </template>

i can use the move method like this: this.$refs.pick.$refs.calendar.move(my date);

but when i add the template with the slot, it's not working anymore. VueJs tells me that is an undefined function. Do you have any idea how to solve this please? Is it possible to use, in the same time, the move method and the datepicker with the input slot? Thanks a lot

LelandB commented 4 years ago

@GrandOurs35 I am running into the same issue, I tried this this.$refs.my_ref.$options.parent.$refs.calendar but got back that move is not a function

nathanreyes commented 4 years ago

It could be a timing issue. When using a slot, the calendar ref element won't exist until the popover is displayed.

If the picker is displayed inline (without a slot), the calendar is always visible, so the ref element will always exist.

Are you trying to move right when the calendar popover is displayed? Or some time after that?

FYI...the next version will add a move function to the date picker as a simple wrapper for the calendar method. The same conditions explained above will apply. It will just be easier to call this.$refs.pick.move() in the future.

QuadeHale commented 3 years ago

I too am having this issue - I eventually dug it out with this.$refs.datePicker.$refs.calendar.focusDate(val.end) as an inline element. Glad to see there will be a wrapper added, thanks!

nathanreyes commented 3 years ago

The wrapper was added in 2.1.1. Going to close this issue upon further feedback or replication repo.