@@ -342,14 +342,17 @@ class DateRangePicker extends BaseComponent {
342342 } )
343343
344344 EventHandler . on ( this . _startInput , EVENT_INPUT , event => {
345- const date = this . _config . inputDateParse ?
346- this . _config . inputDateParse ( event . target . value ) :
347- getLocalDateFromString ( event . target . value , this . _config . locale , this . _config . timepicker )
345+ const date = this . _parseDate ( event . target . value )
348346
349- if ( date instanceof Date && date . getTime ( ) ) {
347+ // valid date or empty date
348+ if ( ( date instanceof Date && ! isNaN ( date ) ) || ( date === null ) ) {
350349 this . _startDate = date
351350 this . _calendarDate = date
352351 this . _calendar . update ( this . _getCalendarConfig ( ) )
352+
353+ EventHandler . trigger ( this . _element , EVENT_START_DATE_CHANGE , {
354+ date : date
355+ } )
353356 }
354357 } )
355358
@@ -381,13 +384,17 @@ class DateRangePicker extends BaseComponent {
381384 } )
382385
383386 EventHandler . on ( this . _endInput , EVENT_INPUT , event => {
384- const date = this . _config . inputDateParse ?
385- this . _config . inputDateParse ( event . target . value ) :
386- getLocalDateFromString ( event . target . value , this . _config . locale , this . _config . timepicker )
387- if ( date instanceof Date && date . getTime ( ) ) {
387+ const date = this . _parseDate ( event . target . value )
388+
389+ // valid date or empty date
390+ if ( ( date instanceof Date && ! isNaN ( date ) ) || ( date === null ) ) {
388391 this . _endDate = date
389392 this . _calendarDate = date
390393 this . _calendar . update ( this . _getCalendarConfig ( ) )
394+
395+ EventHandler . trigger ( this . _element , EVENT_END_DATE_CHANGE , {
396+ date : date
397+ } )
391398 }
392399 } )
393400
@@ -837,7 +844,19 @@ class DateRangePicker extends BaseComponent {
837844 this . _popper = Popper . createPopper ( this . _togglerElement , this . _menu , popperConfig )
838845 }
839846
847+ _parseDate ( str ) {
848+ if ( ! str )
849+ return null ;
850+
851+ return this . _config . inputDateParse ?
852+ this . _config . inputDateParse ( str ) :
853+ getLocalDateFromString ( str , this . _config . locale , this . _config . timepicker )
854+ }
855+
840856 _formatDate ( date ) {
857+ if ( ! date )
858+ return '' ;
859+
841860 if ( this . _config . inputDateFormat ) {
842861 return this . _config . inputDateFormat (
843862 date instanceof Date ? new Date ( date ) : convertToDateObject ( date , this . _config . selectionType )
0 commit comments