semantic-ui-calendar-react
semantic-ui-calendar-react copied to clipboard
Calendar Crashes when minDate and maxDate are used with dates in the past
Bug: When minDate and maxDate are both used for dates in the past, the calendar crashes on opening.
To Reproduce
- Initialise a new DateInput object
- Set the minDate to {Moment("2019-03-01")}
- Set the maxDate to {Moment("2019-03-29")}
- Launch App and attempt to click the Calendar input field.
Expected behavior The calendar should open with the correct min and max date range, but have no date selected.
Dependencies versions Provide version numbers of following packages:
- semantic-ui-react - 0.86.0
- semantic-ui-css (or any alternative) - 2.4.1
- semantic-ui-calendar-react - 0.14.4
We need to know on which month to open a calendar. By default it opens on current month. You have an option to set initialDate
on DateInput. For example, if you set initialDate={moment('2017-01-01')}
, popup will open on Jan 2017. You can circumvent this error by setting meaningful initialDate
(inside [minDate, maxDate] interval).
I will probably fix it by computing default initial date depending on given minDate
and maxDate
.
We need to know on which month to open a calendar. By default it opens on current month. You have an option to set
initialDate
on DateInput. For example, if you setinitialDate={moment('2017-01-01')}
, popup will open on Jan 2017. You can circumvent this error by setting meaningfulinitialDate
(inside [minDate, maxDate] interval).I will probably fix it by computing default initial date depending on given
minDate
andmaxDate
.
initialDate was not fix problem, we use value attribute by default may be it overrides initialDate's value.
I can confirm initialDate doesn't fix the problem, maybe, if can somehow travel to the minDate month, probably there selectable[0].position
will have at least one value, so that it doesn't crash.
if(selectable[0] === undefined)
{ check if we have a minDate or maxDate Property if yes month = minDate(month) and selectable[0] = minDate
Fixed in #140.
@sevketriza Yes, value
prop has precedence over initialDate
. Value is parsed and start date is used as initialDate
. So when you have value
that doesn't fit maxDate
or minDate
you get an error.
I am getting the same issue in DateInput on maxDate & minDate. I can able to set initialDate first time only after reset i can't set initalDate.
Kindle do the needful.