mymth / vanillajs-datepicker

A vanilla JavaScript remake of bootstrap-datepicker for Bulma and other CSS frameworks
MIT License
743 stars 154 forks source link

updateOnBlur not working for Rangepicker #145

Closed MerionLial closed 1 year ago

MerionLial commented 1 year ago

For regular Datepickers the updateOnBlur works fine. As every other option I tried also worked for the Rangepicker, I was suprised to find that this is not the case for updateOnBlur. If the typed in text in the input field is followed up with Enter, the content is sent to the picker, otherwise not.

Is this a bug or an error on my end?

Here's my code for reference:

let filter_vacation_form=document.getElementById("filter_accepted_vacations");
  if(filter_vacation_form){
    //create a rangepicker for start and end
    new DateRangePicker(filter_vacation_form,{
      autohide: true,
      format: "dd.mm.yyyy",
      daysOfWeekDisabled: [0,6],
      weekStart: 1,
      updateOnBlur: true
    });
  }
mymth commented 1 year ago

I tried your code and encountered the same problem. I was surprised too and started trying to find out why. Then, after some trial and error, I noticed I was entering a Saturday's date by unconsciously typing the date in the mm/dd order... (oh boy...) Anyway, it seems like working. I also checked it on the online demo and it worked as expected.

The picker's behavior in your explanation sounds like the one when updateOnBlur is false to me. Since the option is true by default, could you try omitting all the options and check what will happen?

MerionLial commented 1 year ago

Sometimes I doubt my self... You're absolutely right, I too did use a saturday (01.01.2022) and if I either use a valid week day or remove the daysOfWeekDisabled condition, it works fine.

Sorry to have wasted your time with something I should absolutely have caught myself.