longbill / jquery-date-range-picker

A jQuery plugin that allows user to select a date range
MIT License
1.12k stars 579 forks source link

Bugfix/#412, #452 - Fix out-of-bounds options when building the month/year selects #455

Closed monovertex closed 5 years ago

monovertex commented 5 years ago

Previously, when building the month select, the current month was taken out of the available options from the generated range (bound between startDate / 0 and endDate / 11). However, when the selected date range was in the same month as endDate, for all months after the endDate's month, the select would no longer display the proper current month, as it was no longer visible in the available options.

This issue was presented in #412. However, the fix introduced there, which modified the available months range, breaks the month select, because it always limits the range to the current month, not allowing the user to select months past the currently visible month in the picker. This issue is reported in #452.

The proper fix was to update the select builder so that it can display disabled options, thus allowing the selected month to be displayed in the dropdown and properly build the control, without allowing the user to actually select that option. This should make the control more robust and keep the user happy.

Closes #412. Closes #452.

JSFiddle showcasing the fixed version.