wakirin / Litepicker

Date range picker - lightweight, no dependencies
MIT License
899 stars 132 forks source link

Clicking a range no longer auto applies dates #198

Closed harrington101 closed 3 years ago

harrington101 commented 3 years ago

Describe the bug I updated to version 2.0.9 from 1.x. When clicking on a range the calendar changes but the apply is no longer automatic. I have autoApply set to false when it is a date range. Previously, with this setting when the user clicked around the calendar it wouldn't automatically apply the dates until they clicked the apply button but if they clicked a predefined range it would still auto apply. Now it seems there is no way to have this behavior.

To Reproduce Steps to reproduce the behavior:

  1. Create a date picker with autoApply set to false, singleMode set to false, and splitView set to True.

Expected behavior The user can click several dates without auto apply but if they click a range button auto apply happens.

wakirin commented 3 years ago

I believe the behavior is correct now. autoApply is false so we only preselect dates without selected them.

It may be necessary to add another option for ranges or add some kind of event on preselection.

For example with event:

picker.on('ranges:preselect', (d1, d2) => {
  picker.setDateRange(d1, d2);
  picker.hide();
})

Suggestions are welcome.

harrington101 commented 3 years ago

Yes. Or possibly add an option such as "autoApplyRange: true|false". Then autoApply will only apply to the selecting of individual dates.

wakirin commented 3 years ago

I think nothing is in the way to add both things. I will add a new option and events in the next release.

wakirin commented 3 years ago

v2.0.10 Added a new option: https://litepicker.com/docs/plugins/ranges/#autoapply-2010