@@ -206,7 +206,8 @@ class DateRangePicker extends DatePicker {
206206
207207 this . _calendar . selectedDates = this . dateIntervalArrayBuilder ( this . _firstDateTimestamp * 1000 , this . _lastDateTimestamp * 1000 ) ;
208208 this . value = this . _formatValue ( this . _firstDateTimestamp , this . _lastDateTimestamp ) ;
209- this . _prevValue = this . value ;
209+ this . realValue = this . value ;
210+ this . _prevValue = this . realValue ;
210211 }
211212
212213 _changeCalendarSelection ( focusTimestamp ) {
@@ -217,23 +218,23 @@ class DateRangePicker extends DatePicker {
217218
218219 const oCalDate = this . _calendarDate ,
219220 timestamp = focusTimestamp || oCalDate . valueOf ( ) / 1000 ,
220- dates = this . _splitValueByDelimiter ( this . value ) ;
221+ dates = this . _splitValueByDelimiter ( this . realValue ) ;
221222
222223 if ( this . _initialRendering ) {
223224 this . _oneTimeStampSelected = dates [ 0 ] . trim ( ) === dates [ 1 ] . trim ( ) ;
224- this . _setValue ( this . value ) ;
225+ this . _setValue ( this . realValue ) ;
225226 }
226227
227228 this . _calendar = Object . assign ( { } , this . _calendar ) ;
228229 this . _calendar . timestamp = timestamp ;
229- if ( this . value && this . _checkValueValidity ( this . value ) ) {
230+ if ( this . realValue && this . _checkValueValidity ( this . realValue ) ) {
230231 this . _calendar . selectedDates = this . dateIntervalArrayBuilder ( this . _getTimeStampFromString ( dates [ 0 ] ) , this . _getTimeStampFromString ( dates [ 1 ] ) ) ;
231232 }
232233 }
233234
234235 get _calendarDate ( ) {
235- const dates = this . _splitValueByDelimiter ( this . value ) ,
236- value = this . _checkValueValidity ( this . value ) ? dates [ 0 ] : this . getFormat ( ) . format ( new Date ( ) ) ,
236+ const dates = this . _splitValueByDelimiter ( this . realValue ) ,
237+ value = this . _checkValueValidity ( this . realValue ) ? dates [ 0 ] : this . getFormat ( ) . format ( new Date ( ) ) ,
237238 millisecondsUTCFirstDate = value ? this . getFormat ( ) . parse ( value , true ) . getTime ( ) : this . getFormat ( ) . parse ( this . validValue , true ) . getTime ( ) ,
238239 oCalDateFirst = CalendarDate . fromTimestamp (
239240 millisecondsUTCFirstDate - ( millisecondsUTCFirstDate % ( 24 * 60 * 60 * 1000 ) ) ,
@@ -243,6 +244,10 @@ class DateRangePicker extends DatePicker {
243244 return oCalDateFirst ;
244245 }
245246
247+ get _shoudHideValueInInput ( ) {
248+ return this . _firstDateTimestamp === this . _lastDateTimestamp && this . _firstDateTimestamp ;
249+ }
250+
246251 /**
247252 * Currently selected first date represented as JavaScript Date instance.
248253 *
@@ -303,6 +308,10 @@ class DateRangePicker extends DatePicker {
303308 return this . isValid ( value ) && this . isInValidRange ( value ) ;
304309 }
305310
311+ checkRealValueValidity ( ) {
312+ return this . isValid ( this . realValue ) && this . isInValidRange ( this . realValue ) ;
313+ }
314+
306315 isValid ( value ) {
307316 const dateStrings = this . _splitValueByDelimiter ( value , this . delimiter ) ,
308317 isFirstDateValid = super . isValid ( dateStrings [ 0 ] ) ,
@@ -363,9 +372,9 @@ class DateRangePicker extends DatePicker {
363372 const fireChange = this . _handleCalendarSelectedDatesChange ( ) ;
364373
365374 if ( fireChange ) {
366- this . fireEvent ( "change" , { value : this . value , valid : true } ) ;
375+ this . fireEvent ( "change" , { value : this . realValue , valid : true } ) ;
367376 // Angular two way data binding
368- this . fireEvent ( "value-changed" , { value : this . value , valid : true } ) ;
377+ this . fireEvent ( "value-changed" , { value : this . realValue , valid : true } ) ;
369378 }
370379 }
371380 }
@@ -378,7 +387,7 @@ class DateRangePicker extends DatePicker {
378387 this . _calendar . selectedDates = this . dateIntervalArrayBuilder ( this . _firstDateTimestamp * 1000 , this . _lastDateTimestamp * 1000 ) ;
379388 this . _focusInputAfterClose = true ;
380389
381- if ( this . isInValidRange ( this . value ) ) {
390+ if ( this . isInValidRange ( this . realValue ) ) {
382391 this . valueState = ValueState . None ;
383392 } else {
384393 this . valueState = ValueState . Error ;
@@ -402,8 +411,12 @@ class DateRangePicker extends DatePicker {
402411
403412 _updateValueCalendarSelectedDatesChange ( ) {
404413 // Collect both dates and merge them into one
405- this . value = this . _formatValue ( this . _firstDateTimestamp , this . _lastDateTimestamp ) ;
406- this . _prevValue = this . value ;
414+ if ( this . _firstDateTimestamp !== this . _lastDateTimestamp || this . _oneTimeStampSelected ) {
415+ this . value = this . _formatValue ( this . _firstDateTimestamp , this . _lastDateTimestamp ) ;
416+ }
417+
418+ this . realValue = this . _formatValue ( this . _firstDateTimestamp , this . _lastDateTimestamp ) ;
419+ this . _prevValue = this . realValue ;
407420 }
408421
409422 _formatValue ( firstDateValue , lastDateValue ) {
0 commit comments