react-bootstrap-datetimepicker
react-bootstrap-datetimepicker copied to clipboard
Initially setting a null dateTime breaks the datepicker
Setting a null value initially for the datepicker (or an empty string for that matter) breaks the datepicker. If it is passed a null
value, the calendar isn't even shown and there is a NaN
title. If passed an empty string, the calendar is shown, but the internal state's selectedDate
is invalid, and since every new value is cloned from it, all further values are invalid and the onChange always returns an "invalid date" string.
It would be nice to support a null value in the DateTimeField
since sometimes in forms the dates are optional.
+1 I would like this also
to empty the input field you have to set an empty default text (see #69): defaultText=""
Here's a workaround for this issue:
<DateTimeField
inputFormat={ humanDateTimeFormat }
onChange={ this.onDateTimeChange }
defaultText={ this.state.date ? moment(this.state.date, 'x').format(humanDateTimeFormat) : '' }
dateTime={ this.state.date || undefined }
/>
I'd like to see this issue getting fixed. Optional input fields are quite common usecase.
:baby_chick:
I'd love to see this get addressed too...
+1 here! Me too.
:+1: +1 here. As @jozan says, this is a very common usecase, especially with dynamically generated forms.
:+1: +1 from me - pretty sure it's messing us up in Redux app.
However, suggestion above does not work for me - :-1: I get broken calendar, if i supply defaultText, but dateTime is undefined.