@@ -53,6 +53,7 @@ import {
5353 createCounter ,
5454 equal ,
5555 findElementFromEventPath ,
56+ isEmpty ,
5657 last ,
5758} from '../common/util.js' ;
5859import IgcDateTimeInputComponent from '../date-time-input/date-time-input.js' ;
@@ -339,11 +340,7 @@ export default class IgcDateRangePickerComponent extends FormAssociatedRequiredM
339340 }
340341
341342 public get value ( ) : DateRangeValue | null {
342- // TODO what should the default value be? null?
343- return {
344- start : this . _formValue ?. value ?. start ?? null ,
345- end : this . _formValue ?. value ?. end ?? null ,
346- } ;
343+ return this . _formValue . value ;
347344 }
348345 /**
349346 * Renders chips with custom ranges based on the elements of the array.
@@ -627,7 +624,10 @@ export default class IgcDateRangePickerComponent extends FormAssociatedRequiredM
627624 constructor ( ) {
628625 super ( ) ;
629626 this . _formValue = createFormValueState < DateRangeValue | null > ( this , {
630- initialValue : null ,
627+ initialValue : {
628+ start : null ,
629+ end : null ,
630+ } ,
631631 transformers : defaultDateRangeTransformers ,
632632 } ) ;
633633
@@ -651,11 +651,6 @@ export default class IgcDateRangePickerComponent extends FormAssociatedRequiredM
651651
652652 protected override formResetCallback ( ) {
653653 super . formResetCallback ( ) ;
654- this . _formValue . setValueAndFormState ( {
655- start : this . _formValue . defaultValue ?. start ?? null ,
656- end : this . _formValue . defaultValue ?. end ?? null ,
657- } ) ;
658-
659654 this . _setCalendarRangeValues ( ) ;
660655 this . _updateMaskedRangeValue ( ) ;
661656 }
@@ -858,13 +853,18 @@ export default class IgcDateRangePickerComponent extends FormAssociatedRequiredM
858853 : { start : currentStart , end : newValue } ;
859854 }
860855
861- // delegate the inputs validity state to the date-range-picker
856+ // Delegates the validity methods of internal input elements
857+ // to the component's own validation logic specific to date-range values.
858+ // Checks for dirty state to avoid unnecessary validation on form reset,
859+ // caused by the inputs value being set.
862860 private _delegateInputsValidity ( ) {
863861 const inputs = this . useTwoInputs ? this . _inputs : [ this . _input ] ;
864862
865863 inputs . forEach ( ( input ) => {
866- input . checkValidity = ( ) => this . checkValidity ( ) ;
867- input . reportValidity = ( ) => this . reportValidity ( ) ;
864+ input . checkValidity = ( ) =>
865+ this . _dirty || ! this . _pristine ? this . checkValidity ( ) : true ;
866+ input . reportValidity = ( ) =>
867+ this . _dirty || ! this . _pristine ? this . reportValidity ( ) : true ;
868868 } ) ;
869869 }
870870
@@ -890,11 +890,11 @@ export default class IgcDateRangePickerComponent extends FormAssociatedRequiredM
890890 this . _inputs [ 1 ] . max = this . _max ;
891891 }
892892 }
893- if ( this . _disabledDates ?. length > 0 ) {
893+ if ( ! isEmpty ( this . disabledDates ) ) {
894894 dates . push ( ...this . disabledDates ) ;
895895 }
896896
897- this . _dateConstraints = dates . length > 0 ? dates : [ ] ;
897+ this . _dateConstraints = isEmpty ( dates ) ? [ ] : dates ;
898898 }
899899
900900 private _updateMaskedRangeValue ( ) {
@@ -1066,8 +1066,9 @@ export default class IgcDateRangePickerComponent extends FormAssociatedRequiredM
10661066 return nothing ;
10671067 }
10681068
1069- const hasHeaderDate =
1070- this . _headerDateSlotItems . length > 0 ? 'header-date' : '' ;
1069+ const hasHeaderDate = isEmpty ( this . _headerDateSlotItems )
1070+ ? ''
1071+ : 'header-date' ;
10711072
10721073 return html `
10731074 < slot name ="title " slot ="title ">
@@ -1110,13 +1111,13 @@ export default class IgcDateRangePickerComponent extends FormAssociatedRequiredM
11101111
11111112 protected renderActions ( ) {
11121113 const slot =
1113- this . _isDropDown || this . _actions . length === 0 ? undefined : 'footer' ;
1114+ this . _isDropDown || isEmpty ( this . _actions ) ? undefined : 'footer' ;
11141115
11151116 // If in dialog mode use the dialog footer slot
11161117 return html `
11171118 < div
11181119 part ="actions "
1119- ?hidden =${ this . _actions . length === 0 }
1120+ ?hidden =${ isEmpty ( this . _actions ) }
11201121 slot =${ ifDefined ( slot ) }
11211122 >
11221123 < slot name ="actions "> </ slot >
@@ -1262,12 +1263,12 @@ export default class IgcDateRangePickerComponent extends FormAssociatedRequiredM
12621263 ${ this . renderCalendarIcon ( ) }
12631264 < slot
12641265 name ="prefix "
1265- slot =${ ifDefined ( this . _prefixes . length > 0 ? 'prefix' : undefined ) }
1266+ slot =${ ifDefined ( isEmpty ( this . _prefixes ) ? undefined : 'prefix' ) }
12661267 > </ slot >
12671268 ${ this . _renderClearIcon ( ) }
12681269 < slot
12691270 name ="suffix "
1270- slot =${ ifDefined ( this . _suffixes . length > 0 ? 'suffix' : undefined ) }
1271+ slot =${ ifDefined ( isEmpty ( this . _suffixes ) ? undefined : 'suffix' ) }
12711272 > </ slot >
12721273 </ igc-input >
12731274 ${ this . renderHelperText ( ) } ${ this . renderPicker ( id ) } ` ;
0 commit comments