@@ -1133,7 +1133,8 @@ describe('IgxSimpleCombo', () => {
1133
1133
FormsModule ,
1134
1134
IgxSimpleComboSampleComponent ,
1135
1135
IgxComboInContainerTestComponent ,
1136
- IgxSimpleComboIconTemplatesComponent
1136
+ IgxSimpleComboIconTemplatesComponent ,
1137
+ IgxSimpleComboDirtyCheckTestComponent
1137
1138
]
1138
1139
} ) . compileComponents ( ) ;
1139
1140
} ) ) ;
@@ -2063,6 +2064,36 @@ describe('IgxSimpleCombo', () => {
2063
2064
2064
2065
expect ( combo . comboInput . value ) . toEqual ( 'ariz' ) ;
2065
2066
} ) ) ;
2067
+
2068
+ it ( 'should not mark form as dirty when tabbing through an empty combo' , fakeAsync ( ( ) => {
2069
+ fixture = TestBed . createComponent ( IgxSimpleComboDirtyCheckTestComponent ) ;
2070
+ fixture . detectChanges ( ) ;
2071
+
2072
+ combo = fixture . componentInstance . combo ;
2073
+ input = fixture . debugElement . query ( By . css ( '.igx-input-group__input' ) ) ;
2074
+ reactiveForm = fixture . componentInstance . form ;
2075
+ fixture . detectChanges ( ) ;
2076
+
2077
+ expect ( reactiveForm . dirty ) . toBe ( false ) ;
2078
+
2079
+ input . nativeElement . focus ( ) ;
2080
+ tick ( ) ;
2081
+ fixture . detectChanges ( ) ;
2082
+
2083
+ UIInteractions . triggerKeyDownEvtUponElem ( 'ArrowDown' , input . nativeElement ) ;
2084
+ tick ( ) ;
2085
+ fixture . detectChanges ( ) ;
2086
+
2087
+ input . nativeElement . focus ( ) ;
2088
+ tick ( ) ;
2089
+ fixture . detectChanges ( ) ;
2090
+
2091
+ UIInteractions . triggerEventHandlerKeyDown ( 'Tab' , input ) ;
2092
+ tick ( ) ;
2093
+ fixture . detectChanges ( ) ;
2094
+
2095
+ expect ( reactiveForm . dirty ) . toBe ( false ) ;
2096
+ } ) ) ;
2066
2097
} ) ;
2067
2098
2068
2099
describe ( 'Display density' , ( ) => {
@@ -3367,3 +3398,42 @@ export class IgxSimpleComboNgModelComponent implements OnInit {
3367
3398
] ;
3368
3399
}
3369
3400
}
3401
+
3402
+ @Component ( {
3403
+ template : `
3404
+ <form [formGroup]="form">
3405
+ <div class="combo-section">
3406
+ <igx-simple-combo
3407
+ #combo
3408
+ [data]="cities"
3409
+ [displayKey]="'name'"
3410
+ [valueKey]="'id'"
3411
+ formControlName="city"
3412
+ >
3413
+ </igx-simple-combo>
3414
+ </div>
3415
+ </form>
3416
+ ` ,
3417
+ standalone : true ,
3418
+ imports : [ IgxSimpleComboComponent , ReactiveFormsModule ]
3419
+ } )
3420
+ export class IgxSimpleComboDirtyCheckTestComponent implements OnInit {
3421
+ @ViewChild ( 'combo' , { read : IgxSimpleComboComponent , static : true } )
3422
+ public combo : IgxSimpleComboComponent ;
3423
+
3424
+ public cities : any = [ ] ;
3425
+
3426
+ public form = new FormGroup ( {
3427
+ city : new FormControl < number > ( { value : undefined , disabled : false } ) ,
3428
+ } ) ;
3429
+
3430
+ public ngOnInit ( ) : void {
3431
+ this . cities = [
3432
+ { id : 1 , name : 'New York' } ,
3433
+ { id : 2 , name : 'Los Angeles' } ,
3434
+ { id : 3 , name : 'Chicago' } ,
3435
+ { id : 4 , name : 'Houston' } ,
3436
+ { id : 5 , name : 'Phoenix' }
3437
+ ] ;
3438
+ }
3439
+ }
0 commit comments