semantic-ui-calendar-react icon indicating copy to clipboard operation
semantic-ui-calendar-react copied to clipboard

Calendar Crashes when minDate and maxDate are used with dates in the past

Open olliebobster opened this issue 5 years ago • 5 comments

Bug: When minDate and maxDate are both used for dates in the past, the calendar crashes on opening.

To Reproduce

  1. Initialise a new DateInput object
  2. Set the minDate to {Moment("2019-03-01")}
  3. Set the maxDate to {Moment("2019-03-29")}
  4. 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

olliebobster avatar Apr 04 '19 23:04 olliebobster

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.

arfedulov avatar Apr 07 '19 03:04 arfedulov

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.

initialDate was not fix problem, we use value attribute by default may be it overrides initialDate's value.

sevketriza avatar Apr 22 '19 06:04 sevketriza

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

SarasArya avatar Apr 30 '19 05:04 SarasArya

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.

arfedulov avatar May 01 '19 16:05 arfedulov

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.

shahbaz-github avatar Nov 05 '19 08:11 shahbaz-github