@@ -1115,7 +1115,8 @@ describe('IgxSimpleCombo', () => {
1115
1115
IgxSimpleComboSampleComponent ,
1116
1116
IgxComboInContainerTestComponent ,
1117
1117
IgxSimpleComboIconTemplatesComponent ,
1118
- IgxSimpleComboDirtyCheckTestComponent
1118
+ IgxSimpleComboDirtyCheckTestComponent ,
1119
+ IgxSimpleComboTabBehaviorTestComponent
1119
1120
]
1120
1121
} ) . compileComponents ( ) ;
1121
1122
} ) ) ;
@@ -2109,6 +2110,35 @@ describe('IgxSimpleCombo', () => {
2109
2110
2110
2111
expect ( reactiveForm . dirty ) . toBe ( false ) ;
2111
2112
} ) ) ;
2113
+
2114
+ it ( 'should focus on the next combo when Tab is pressed' , fakeAsync ( ( ) => {
2115
+ fixture = TestBed . createComponent ( IgxSimpleComboTabBehaviorTestComponent ) ;
2116
+ fixture . detectChanges ( ) ;
2117
+
2118
+ const combos = fixture . debugElement . queryAll ( By . directive ( IgxSimpleComboComponent ) ) ;
2119
+ expect ( combos . length ) . toBe ( 3 ) ;
2120
+
2121
+ const firstComboInput = combos [ 0 ] . query ( By . css ( `.${ CSS_CLASS_COMBO_INPUTGROUP } ` ) ) ;
2122
+ const secondComboInput = combos [ 1 ] . query ( By . css ( `.${ CSS_CLASS_COMBO_INPUTGROUP } ` ) ) ;
2123
+ const thirdComboInput = combos [ 2 ] . query ( By . css ( `.${ CSS_CLASS_COMBO_INPUTGROUP } ` ) ) ;
2124
+
2125
+ firstComboInput . nativeElement . focus ( ) ;
2126
+ tick ( ) ;
2127
+ fixture . detectChanges ( ) ;
2128
+ expect ( document . activeElement ) . toEqual ( firstComboInput . nativeElement ) ;
2129
+
2130
+ UIInteractions . triggerEventHandlerKeyDown ( 'Tab' , firstComboInput ) ;
2131
+ secondComboInput . nativeElement . focus ( ) ;
2132
+ tick ( ) ;
2133
+ fixture . detectChanges ( ) ;
2134
+ expect ( document . activeElement ) . toEqual ( secondComboInput . nativeElement ) ;
2135
+
2136
+ UIInteractions . triggerEventHandlerKeyDown ( 'Tab' , secondComboInput ) ;
2137
+ thirdComboInput . nativeElement . focus ( ) ;
2138
+ tick ( ) ;
2139
+ fixture . detectChanges ( ) ;
2140
+ expect ( document . activeElement ) . toEqual ( thirdComboInput . nativeElement ) ;
2141
+ } ) ) ;
2112
2142
} ) ;
2113
2143
2114
2144
describe ( 'Form control tests: ' , ( ) => {
@@ -3407,3 +3437,61 @@ export class IgxSimpleComboDirtyCheckTestComponent implements OnInit {
3407
3437
] ;
3408
3438
}
3409
3439
}
3440
+
3441
+ @Component ( {
3442
+ template : `
3443
+ <form [formGroup]="form">
3444
+ <div class="combo-section">
3445
+ <igx-simple-combo
3446
+ #combo
3447
+ [data]="cities"
3448
+ [displayKey]="'name'"
3449
+ [valueKey]="'id'"
3450
+ formControlName="city"
3451
+ >
3452
+ </igx-simple-combo>
3453
+ <igx-simple-combo
3454
+ #combo2
3455
+ [data]="cities"
3456
+ [displayKey]="'name'"
3457
+ [valueKey]="'id'"
3458
+ formControlName="city2"
3459
+ ></igx-simple-combo>
3460
+ <igx-simple-combo
3461
+ #combo3
3462
+ [data]="cities"
3463
+ [displayKey]="'name'"
3464
+ [valueKey]="'id'"
3465
+ formControlName="city3"
3466
+ ></igx-simple-combo>
3467
+ </div>
3468
+ </form>
3469
+ ` ,
3470
+ imports : [ IgxSimpleComboComponent , ReactiveFormsModule ]
3471
+ } )
3472
+ export class IgxSimpleComboTabBehaviorTestComponent implements OnInit {
3473
+ @ViewChild ( 'combo' , { read : IgxSimpleComboComponent , static : true } )
3474
+ public combo : IgxSimpleComboComponent ;
3475
+ @ViewChild ( 'combo2' , { read : IgxSimpleComboComponent , static : true } )
3476
+ public combo2 : IgxSimpleComboComponent ;
3477
+ @ViewChild ( 'combo3' , { read : IgxSimpleComboComponent , static : true } )
3478
+ public combo3 : IgxSimpleComboComponent ;
3479
+
3480
+ public cities = [ ] ;
3481
+
3482
+ public form = new FormGroup ( {
3483
+ city : new FormControl < number > ( { value : undefined , disabled : false } ) ,
3484
+ city2 : new FormControl < number > ( { value : undefined , disabled : false } ) ,
3485
+ city3 : new FormControl < number > ( { value : undefined , disabled : false } ) ,
3486
+ } ) ;
3487
+
3488
+ public ngOnInit ( ) : void {
3489
+ this . cities = [
3490
+ { id : 1 , name : 'New York' } ,
3491
+ { id : 2 , name : 'Los Angeles' } ,
3492
+ { id : 3 , name : 'Chicago' } ,
3493
+ { id : 4 , name : 'Houston' } ,
3494
+ { id : 5 , name : 'Phoenix' }
3495
+ ] ;
3496
+ }
3497
+ }
0 commit comments