Datepicker defaultValue not being selected in the calendar when minDate is set
See original GitHub issueDescription
When creating a DatePicker component with minDate
and defaultValue
props set, the defaultValue
is shown in the date text field, but not in the picker itself. The datepicker just shows the current day as the selected day.
I have tried this by setting the defaultValue
prop equal to both a date object and a string. I have tried this using the value
prop with no success. I have also tried to use the initialCalendarDate
prop alongside value
and/or defaultValue
without success.
The interesting part is that the defaultValue
or value
prop will be selected in the calendar if a minDate
is not set.
Images/Screenshots
In this case, the defaultValue
is equal to “2/12/2017” from the store.
Code Sample
<DatePicker
id="campaign-start-date"
label="Start Date"
onChange={(dateString) => onStartDateChange(dateString)}
minDate={new Date()}
maxDate={new Date(new Date(endDate).getTime() - millisecondsPerDay)}
initialCalendarDate={startDate}
defaultValue={startDate}
inline={true}
/>
startDate
is equal to “2/12/2017” from the store
endDate
is equal to “2/20/2017” from the store
onStartDateChange
just changes the value of startDate in the store
milisecondsPerDay
is a const that equals 86400000 (this is so the max date can never be >= the endDate)
Version
- React 15.4.2
- React-MD 1.0.1
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (2 by maintainers)
Oh awesome! I think it was related to 53130fa
Yep! That’s the case. Good to know, I will make sure to use the
value
prop when I need control.