@@ -1017,7 +1017,8 @@ describe('IgxSimpleCombo', () => {
10171017 FormsModule ,
10181018 IgxSimpleComboSampleComponent ,
10191019 IgxComboInContainerTestComponent ,
1020- IgxSimpleComboIconTemplatesComponent
1020+ IgxSimpleComboIconTemplatesComponent ,
1021+ IgxSimpleComboDirtyCheckTestComponent
10211022 ]
10221023 } ) . compileComponents ( ) ;
10231024 } ) ) ;
@@ -1947,6 +1948,36 @@ describe('IgxSimpleCombo', () => {
19471948
19481949 expect ( combo . comboInput . value ) . toEqual ( 'ariz' ) ;
19491950 } ) ) ;
1951+
1952+ it ( 'should not mark form as dirty when tabbing through an empty combo' , fakeAsync ( ( ) => {
1953+ fixture = TestBed . createComponent ( IgxSimpleComboDirtyCheckTestComponent ) ;
1954+ fixture . detectChanges ( ) ;
1955+
1956+ combo = fixture . componentInstance . combo ;
1957+ input = fixture . debugElement . query ( By . css ( '.igx-input-group__input' ) ) ;
1958+ reactiveForm = fixture . componentInstance . form ;
1959+ fixture . detectChanges ( ) ;
1960+
1961+ expect ( reactiveForm . dirty ) . toBe ( false ) ;
1962+
1963+ input . nativeElement . focus ( ) ;
1964+ tick ( ) ;
1965+ fixture . detectChanges ( ) ;
1966+
1967+ UIInteractions . triggerKeyDownEvtUponElem ( 'ArrowDown' , input . nativeElement ) ;
1968+ tick ( ) ;
1969+ fixture . detectChanges ( ) ;
1970+
1971+ input . nativeElement . focus ( ) ;
1972+ tick ( ) ;
1973+ fixture . detectChanges ( ) ;
1974+
1975+ UIInteractions . triggerEventHandlerKeyDown ( 'Tab' , input ) ;
1976+ tick ( ) ;
1977+ fixture . detectChanges ( ) ;
1978+
1979+ expect ( reactiveForm . dirty ) . toBe ( false ) ;
1980+ } ) ) ;
19501981 } ) ;
19511982
19521983 describe ( 'Display density' , ( ) => {
@@ -3198,3 +3229,42 @@ export class IgxSimpleComboNgModelComponent implements OnInit {
31983229 ] ;
31993230 }
32003231}
3232+
3233+ @Component ( {
3234+ template : `
3235+ <form [formGroup]="form">
3236+ <div class="combo-section">
3237+ <igx-simple-combo
3238+ #combo
3239+ [data]="cities"
3240+ [displayKey]="'name'"
3241+ [valueKey]="'id'"
3242+ formControlName="city"
3243+ >
3244+ </igx-simple-combo>
3245+ </div>
3246+ </form>
3247+ ` ,
3248+ standalone : true ,
3249+ imports : [ IgxSimpleComboComponent , ReactiveFormsModule ]
3250+ } )
3251+ export class IgxSimpleComboDirtyCheckTestComponent implements OnInit {
3252+ @ViewChild ( 'combo' , { read : IgxSimpleComboComponent , static : true } )
3253+ public combo : IgxSimpleComboComponent ;
3254+
3255+ public cities : any = [ ] ;
3256+
3257+ public form = new FormGroup ( {
3258+ city : new FormControl < number > ( { value : undefined , disabled : false } ) ,
3259+ } ) ;
3260+
3261+ public ngOnInit ( ) : void {
3262+ this . cities = [
3263+ { id : 1 , name : 'New York' } ,
3264+ { id : 2 , name : 'Los Angeles' } ,
3265+ { id : 3 , name : 'Chicago' } ,
3266+ { id : 4 , name : 'Houston' } ,
3267+ { id : 5 , name : 'Phoenix' }
3268+ ] ;
3269+ }
3270+ }
0 commit comments