Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

defaultDate Option interface does not support 'multiple' or 'range' modes #73

Open
MHL-Galen opened this issue Aug 29, 2019 · 3 comments

Comments

@MHL-Galen
Copy link

The FlatpickrOptions interface currently sets defaultDate type as string | Date. For 'multiple' and 'range' type instances the default date needs to be an array of strings or dates - see Flatpickr options.

In my local instance I have changed the defaultDate interface to accept string | string[] | Date | Date[] and can confirm that it works with date ranges but it would be good to see this implemented officially.

@mezoistvan
Copy link
Owner

The FlatpickrOptions interface is unnecessary, should be removed and replaced with the BaseOptions interface from flatpickr.

@ghost
Copy link

ghost commented Mar 21, 2020

Yep, all fine with using BaseOptions, except you must declare it as Partial<BaseOptions> as flatpickr BaseOptions properties are all probably generated as required:

public flatpickrOptions: Partial<BaseOptions> = {
    inline: true,
    mode: 'multiple',
    defaultDate: this.multiDates
  };

@abdulbasit1248
Copy link

I found a fix for this. Basically, I was using two packages in my rails application. The problem is that the stimulus searches for the respective controller name. If we will not provide it gets confused as that which controller is targeting the data attributes.

"stimulus": "^2.0.0",
"stimulus-flatpickr": "^1.4.0",
<div class="form-group flatpicker">
      <%= f.label :days_closed, class: 'form-control-label font-weight-bold' %><br>
      <%= f.text_field :days_closed, class: 'form-control flatpickr-input active selected_date', data: {
        mode: 'multiple',
        behavior: 'flatpickr_date',
        controller: "flatpickr",
        flatpickr_date_format: "Y-m-d",
        flatpickr_alt_input: true,
        flatpickr_default_date: month_goal.days_closed,
        alt_input: true } %>
</div>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants