mymth / vanillajs-datepicker

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

Add option or fix when clicking to the next month when maxDate spills into next month #38

Closed bkmorse closed 3 years ago

bkmorse commented 3 years ago

Screen Shot 2020-09-28 at 4 40 08 PM

I set it to have a date range within 3 days, so if it were September 30th, it would allow them to pick between September 30th, October 1st, October 2, as seen in the image attached.

var date = new Date();
var minDate = new Date();
var maxDate = date.setDate(date.getDate() + 2);

var datepicker = new Datepicker(elem, {
    minDate: minDate, 
    maxDate: maxDate,
    autohide: true,
});

When I clicking the next arrow in the top right, it does nothing. When I hover the previous arrow (top left) it shows an icon visually letting me know that is not an option.

Option 1: can you at least allow for the user to click to the next month if the maxDate spills into the next month?

Another option is to add a new option that allows for only showing that current month's dates, so it would not show the August 30, 31 as the first two dates, as well as hiding October 1-10, and allowing to click next to view October, so the user can click the 1st or 2nd date?

Option 1 seems the easiest.

mymth commented 3 years ago

I can't reproduce the problem. The date picker is programed to disable the next button when calendar's month (the month displayed between the prev/next buttons) is the same month as the maxDate's (or later), https://github.com/mymth/vanillajs-datepicker/blob/352c426c8ec0459c23de08646f0c1fc191b7f6f4/js/picker/views/DaysView.js#L139