@@ -208,8 +208,12 @@ export default class DateTimePicker extends Component {
208208 }
209209
210210 render ( ) {
211- const JSDate = new Date ( this . getAdjustedPlotlyJSDateTime ( this . props . value ) ) ;
212- const currentYear = JSDate . getFullYear ( ) ;
211+ const JSDate = new Date (
212+ this . getAdjustedPlotlyJSDateTime ( this . state . dateValue + ' ' + testTime )
213+ ) ;
214+ const isValidJSDate = JSDate . toDateString ( ) !== 'Invalid Date' ;
215+ const currentYear = isValidJSDate ? JSDate . getFullYear ( ) : new Date ( ) . getFullYear ( ) ;
216+ const currentMonth = isValidJSDate ? JSDate . getMonth ( ) : new Date ( ) . getMonth ( ) ;
213217
214218 return (
215219 < div className = "datetimepicker-container" >
@@ -237,7 +241,7 @@ export default class DateTimePicker extends Component {
237241 < div className = "datetimepicker-datepicker-navbar" >
238242 < Dropdown
239243 options = { this . getMonthOptions ( ) }
240- value = { JSDate . getMonth ( ) }
244+ value = { currentMonth }
241245 className = "datimepicker-monthpicker"
242246 clearable = { false }
243247 onChange = { this . onMonthChange }
@@ -252,8 +256,8 @@ export default class DateTimePicker extends Component {
252256 </ div >
253257 < DayPicker
254258 className = "datepicker-container-rce"
255- modifiers = { { highlighted : JSDate } }
256- month = { JSDate }
259+ modifiers = { { highlighted : isValidJSDate ? JSDate : '' } }
260+ month = { isValidJSDate ? JSDate : new Date ( ) }
257261 onDayClick = { value => {
258262 const plotlyDate = this . toPlotlyJSDate ( value ) . split ( ' ' ) [ 0 ] ;
259263 this . onDateChange ( plotlyDate ) ;
0 commit comments