Skip to content

Commit 217604e

Browse files
authored
fix(simple-combo): remove text selection trigger and add test (#15468)
1 parent 5190bc1 commit 217604e

File tree

2 files changed

+90
-3
lines changed

2 files changed

+90
-3
lines changed

projects/igniteui-angular/src/lib/simple-combo/simple-combo.component.spec.ts

Lines changed: 89 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,8 @@ describe('IgxSimpleCombo', () => {
11151115
IgxSimpleComboSampleComponent,
11161116
IgxComboInContainerTestComponent,
11171117
IgxSimpleComboIconTemplatesComponent,
1118-
IgxSimpleComboDirtyCheckTestComponent
1118+
IgxSimpleComboDirtyCheckTestComponent,
1119+
IgxSimpleComboTabBehaviorTestComponent
11191120
]
11201121
}).compileComponents();
11211122
}));
@@ -2109,6 +2110,35 @@ describe('IgxSimpleCombo', () => {
21092110

21102111
expect(reactiveForm.dirty).toBe(false);
21112112
}));
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+
}));
21122142
});
21132143

21142144
describe('Form control tests: ', () => {
@@ -3407,3 +3437,61 @@ export class IgxSimpleComboDirtyCheckTestComponent implements OnInit {
34073437
];
34083438
}
34093439
}
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+
}

projects/igniteui-angular/src/lib/simple-combo/simple-combo.component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,9 +465,8 @@ export class IgxSimpleComboComponent extends IgxComboBaseDirective implements Co
465465
}
466466

467467
this.composing = false;
468-
// explicitly update selection and trigger text selection so that we don't have to force CD
468+
// explicitly update selection so that we don't have to force CD
469469
this.textSelection.selected = true;
470-
this.textSelection.trigger();
471470
}
472471

473472
/** @hidden @internal */

0 commit comments

Comments
 (0)