Litepicker icon indicating copy to clipboard operation
Litepicker copied to clipboard

[multiselect] preMultipleDates get removed when setting options

Open nyroDev opened this issue 4 years ago • 2 comments

Describe the bug When using the setOptions inside a multiselect.select event, preselected get cleared.

To Reproduce Steps to reproduce the behavior:

  1. Go to https://codepen.io/nyroDev/pen/mdOowPW?editors=1011
  2. Click on any date in the inline calendar
  3. See that this date is not selected

Expected behavior preMultipleDates get cleared when calling the setOptions function, so the dates get cleared. It should not be cleared

Additional context What I'm trying to do is a multiselect picker restricted to only 1 month.
As a far as the user select the first date, I'm settings the options minDate and maxDate to restrict to the month.
I saw that the preMultipleDates is used internally in order to maintain the selected dates before calling the apply buttons. That's why I logged it before and after the setOptions call

I'll add a feature request to add a function to get these dates too, as it's required in my use case.

nyroDev avatar Mar 14 '21 17:03 nyroDev

As a workaround, here is wher I do for now:

  1. Save the preMultipleDates in a var
  2. Do the setOptions
  3. Reset the preMultipleDates
  4. Call goToDate withe the given date

Calling goToDate works because it's not causing the show event, only the render call.

Hre is the codePen: https://codepen.io/nyroDev/pen/jOVJwBe?editors=1011

nyroDev avatar Mar 14 '21 17:03 nyroDev

Please not that the exact same issue occur when calling setOptions from the multiselect.deselect.
The preMultipleDates get reseted to the previous value.

Using the reset preMultipleDates/goToDate works too in this case.

nyroDev avatar Mar 14 '21 17:03 nyroDev