@@ -206,7 +206,8 @@ class DateRangePicker extends DatePicker {
206
206
207
207
this . _calendar . selectedDates = this . dateIntervalArrayBuilder ( this . _firstDateTimestamp * 1000 , this . _lastDateTimestamp * 1000 ) ;
208
208
this . value = this . _formatValue ( this . _firstDateTimestamp , this . _lastDateTimestamp ) ;
209
- this . _prevValue = this . value ;
209
+ this . realValue = this . value ;
210
+ this . _prevValue = this . realValue ;
210
211
}
211
212
212
213
_changeCalendarSelection ( focusTimestamp ) {
@@ -217,23 +218,23 @@ class DateRangePicker extends DatePicker {
217
218
218
219
const oCalDate = this . _calendarDate ,
219
220
timestamp = focusTimestamp || oCalDate . valueOf ( ) / 1000 ,
220
- dates = this . _splitValueByDelimiter ( this . value ) ;
221
+ dates = this . _splitValueByDelimiter ( this . realValue ) ;
221
222
222
223
if ( this . _initialRendering ) {
223
224
this . _oneTimeStampSelected = dates [ 0 ] . trim ( ) === dates [ 1 ] . trim ( ) ;
224
- this . _setValue ( this . value ) ;
225
+ this . _setValue ( this . realValue ) ;
225
226
}
226
227
227
228
this . _calendar = Object . assign ( { } , this . _calendar ) ;
228
229
this . _calendar . timestamp = timestamp ;
229
- if ( this . value && this . _checkValueValidity ( this . value ) ) {
230
+ if ( this . realValue && this . _checkValueValidity ( this . realValue ) ) {
230
231
this . _calendar . selectedDates = this . dateIntervalArrayBuilder ( this . _getTimeStampFromString ( dates [ 0 ] ) , this . _getTimeStampFromString ( dates [ 1 ] ) ) ;
231
232
}
232
233
}
233
234
234
235
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 ( ) ) ,
237
238
millisecondsUTCFirstDate = value ? this . getFormat ( ) . parse ( value , true ) . getTime ( ) : this . getFormat ( ) . parse ( this . validValue , true ) . getTime ( ) ,
238
239
oCalDateFirst = CalendarDate . fromTimestamp (
239
240
millisecondsUTCFirstDate - ( millisecondsUTCFirstDate % ( 24 * 60 * 60 * 1000 ) ) ,
@@ -243,6 +244,10 @@ class DateRangePicker extends DatePicker {
243
244
return oCalDateFirst ;
244
245
}
245
246
247
+ get _shoudHideValueInInput ( ) {
248
+ return this . _firstDateTimestamp === this . _lastDateTimestamp && this . _firstDateTimestamp ;
249
+ }
250
+
246
251
/**
247
252
* Currently selected first date represented as JavaScript Date instance.
248
253
*
@@ -303,6 +308,10 @@ class DateRangePicker extends DatePicker {
303
308
return this . isValid ( value ) && this . isInValidRange ( value ) ;
304
309
}
305
310
311
+ checkRealValueValidity ( ) {
312
+ return this . isValid ( this . realValue ) && this . isInValidRange ( this . realValue ) ;
313
+ }
314
+
306
315
isValid ( value ) {
307
316
const dateStrings = this . _splitValueByDelimiter ( value , this . delimiter ) ,
308
317
isFirstDateValid = super . isValid ( dateStrings [ 0 ] ) ,
@@ -363,9 +372,9 @@ class DateRangePicker extends DatePicker {
363
372
const fireChange = this . _handleCalendarSelectedDatesChange ( ) ;
364
373
365
374
if ( fireChange ) {
366
- this . fireEvent ( "change" , { value : this . value , valid : true } ) ;
375
+ this . fireEvent ( "change" , { value : this . realValue , valid : true } ) ;
367
376
// 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 } ) ;
369
378
}
370
379
}
371
380
}
@@ -378,7 +387,7 @@ class DateRangePicker extends DatePicker {
378
387
this . _calendar . selectedDates = this . dateIntervalArrayBuilder ( this . _firstDateTimestamp * 1000 , this . _lastDateTimestamp * 1000 ) ;
379
388
this . _focusInputAfterClose = true ;
380
389
381
- if ( this . isInValidRange ( this . value ) ) {
390
+ if ( this . isInValidRange ( this . realValue ) ) {
382
391
this . valueState = ValueState . None ;
383
392
} else {
384
393
this . valueState = ValueState . Error ;
@@ -402,8 +411,12 @@ class DateRangePicker extends DatePicker {
402
411
403
412
_updateValueCalendarSelectedDatesChange ( ) {
404
413
// 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 ;
407
420
}
408
421
409
422
_formatValue ( firstDateValue , lastDateValue ) {
0 commit comments