@@ -34,8 +34,8 @@ export const rangeValueManager: RangePickerValueManager = {
34
34
getTodayDate ( utils , timezone , valueType ) ,
35
35
] ,
36
36
getInitialReferenceValue : ( { value, referenceDate : referenceDateProp , ...params } ) => {
37
- const shouldKeepStartDate = value [ 0 ] != null && params . utils . isValid ( value [ 0 ] ) ;
38
- const shouldKeepEndDate = value [ 1 ] != null && params . utils . isValid ( value [ 1 ] ) ;
37
+ const shouldKeepStartDate = params . utils . isValid ( value [ 0 ] ) ;
38
+ const shouldKeepEndDate = params . utils . isValid ( value [ 1 ] ) ;
39
39
40
40
if ( shouldKeepStartDate && shouldKeepEndDate ) {
41
41
return value as PickerNonNullableRangeValue ;
@@ -56,10 +56,8 @@ export const rangeValueManager: RangePickerValueManager = {
56
56
hasError : ( error ) => error [ 0 ] != null || error [ 1 ] != null ,
57
57
defaultErrorState : [ null , null ] ,
58
58
getTimezone : ( utils , value ) => {
59
- const timezoneStart =
60
- value [ 0 ] == null || ! utils . isValid ( value [ 0 ] ) ? null : utils . getTimezone ( value [ 0 ] ) ;
61
- const timezoneEnd =
62
- value [ 1 ] == null || ! utils . isValid ( value [ 1 ] ) ? null : utils . getTimezone ( value [ 1 ] ) ;
59
+ const timezoneStart = utils . isValid ( value [ 0 ] ) ? utils . getTimezone ( value [ 0 ] ) : null ;
60
+ const timezoneEnd = utils . isValid ( value [ 1 ] ) ? utils . getTimezone ( value [ 1 ] ) : null ;
63
61
64
62
if ( timezoneStart != null && timezoneEnd != null && timezoneStart !== timezoneEnd ) {
65
63
throw new Error ( 'MUI X: The timezone of the start and the end date should be the same.' ) ;
@@ -79,8 +77,8 @@ export const getRangeFieldValueManager = ({
79
77
dateSeparator : string | undefined ;
80
78
} ) : FieldValueManager < PickerRangeValue > => ( {
81
79
updateReferenceValue : ( utils , value , prevReferenceValue ) => {
82
- const shouldKeepStartDate = value [ 0 ] != null && utils . isValid ( value [ 0 ] ) ;
83
- const shouldKeepEndDate = value [ 1 ] != null && utils . isValid ( value [ 1 ] ) ;
80
+ const shouldKeepStartDate = utils . isValid ( value [ 0 ] ) ;
81
+ const shouldKeepEndDate = utils . isValid ( value [ 1 ] ) ;
84
82
85
83
if ( ! shouldKeepStartDate && ! shouldKeepEndDate ) {
86
84
return prevReferenceValue ;
@@ -184,10 +182,9 @@ export const getRangeFieldValueManager = ({
184
182
} ,
185
183
getNewValuesFromNewActiveDate : ( newActiveDate ) => ( {
186
184
value : updateDateInRange ( newActiveDate , state . value ) ,
187
- referenceValue :
188
- newActiveDate == null || ! utils . isValid ( newActiveDate )
189
- ? state . referenceValue
190
- : updateDateInRange ( newActiveDate , state . referenceValue ) ,
185
+ referenceValue : ! utils . isValid ( newActiveDate )
186
+ ? state . referenceValue
187
+ : updateDateInRange ( newActiveDate , state . referenceValue ) ,
191
188
} ) ,
192
189
} ;
193
190
} ,
0 commit comments