wakirin / Litepicker

Date range picker - lightweight, no dependencies
MIT License
898 stars 131 forks source link

Inline calendar doesn't 'move to' the predefined selected range #195

Closed mijrs closed 3 years ago

mijrs commented 3 years ago

Describe the bug/problem If you click on a predefined range, the inline calendar doesn't 'move to' the new selected range.

To Reproduce https://jsfiddle.net/Mijrs/2htfd1oy/29/

Click on 'first week January 2021'. You see the calendar stayes at February. Would like the calendar jumped to the selected/clicked period in January.

Expected behaviour After clicking on a predefined range, the inline calendar has to move (show) to the new selected date range.

wakirin commented 3 years ago

I will fix it in the next release. Currently you can fix it with selected event: https://jsfiddle.net/2sLfxjqg/

wakirin commented 3 years ago

fixed in 2.0.9

mijrs commented 3 years ago

I've updated the jsfiddle with 2.0.9, but i don't see a change.

https://jsfiddle.net/Mijrs/2htfd1oy/31/

Am I doing something wrong?

wakirin commented 3 years ago

https://jsfiddle.net/gyqute5b/

Use plugin ranges from 2.0.9 version.

mijrs commented 3 years ago

Thnx!

harrington101 commented 3 years ago

I am using the plugin for ranges. The first calendar moves but the second does not. The calendars are not connected so the user can move one calendar without moving the other in order to select a larger range of dates. Expected behavior: The first calendar should show the start of the range and the second calendar should show the end of the range.

wakirin commented 3 years ago

@harrington101 ~nice catch. I forgot about splitView option.~ ~I will fix it in the next release.~

After a little thought, I think it can be done like this:

...
picker.on('show', () => {
  const options = picker.options;
  const splitShow = options.splitView
    && options.startDate
    && options.endDate
    && options.endDate.isAfter(options.startDate);

    if (splitShow) {
      picker.gotoDate(options.endDate, 1);
    }
});
...

The next release will not contain these changes. I don't think we need to include every specific case in the library.