Skip to content

Commit 42ecf6c

Browse files
Ivan KitanovChronosSF
authored andcommitted
fix(combo): Sync aria required with required state
1 parent f676860 commit 42ecf6c

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

projects/igniteui-angular/src/lib/combo/combo.common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,6 +1343,7 @@ export abstract class IgxComboBaseDirective implements IgxComboBase, AfterViewCh
13431343
protected manageRequiredAsterisk(): void {
13441344
if (this.ngControl) {
13451345
this.inputGroup.isRequired = this.required;
1346+
this.comboInput.nativeElement.setAttribute('aria-required', this.required.toString());
13461347
}
13471348
}
13481349

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3436,8 +3436,11 @@ describe('igxCombo', () => {
34363436
it('should add/remove asterisk when setting validators dynamically', () => {
34373437
let inputGroupIsRequiredClass = fixture.debugElement.query(By.css('.' + CSS_CLASS_INPUTGROUP_REQUIRED));
34383438
let asterisk = window.getComputedStyle(fixture.debugElement.query(By.css('.' + CSS_CLASS_INPUTGROUP_LABEL)).nativeElement, ':after').content;
3439+
input = fixture.debugElement.query(By.css(`.${CSS_CLASS_COMBO_INPUTGROUP}`));
34393440
expect(asterisk).toBe('"*"');
34403441
expect(inputGroupIsRequiredClass).toBeDefined();
3442+
console.log(input.nativeElement);
3443+
expect(input.nativeElement.getAttribute('aria-required')).toMatch('true');
34413444

34423445
fixture.componentInstance.reactiveForm.controls.townCombo.clearValidators();
34433446
fixture.componentInstance.reactiveForm.controls.townCombo.updateValueAndValidity();
@@ -3446,6 +3449,7 @@ describe('igxCombo', () => {
34463449
asterisk = window.getComputedStyle(fixture.debugElement.query(By.css('.' + CSS_CLASS_INPUTGROUP_LABEL)).nativeElement, ':after').content;
34473450
expect(asterisk).toBe('none');
34483451
expect(inputGroupIsRequiredClass).toBeNull();
3452+
expect(input.nativeElement.getAttribute('aria-required')).toMatch('false');
34493453

34503454
fixture.componentInstance.reactiveForm.controls.townCombo.setValidators(Validators.required);
34513455
fixture.componentInstance.reactiveForm.controls.townCombo.updateValueAndValidity();
@@ -3454,6 +3458,7 @@ describe('igxCombo', () => {
34543458
asterisk = window.getComputedStyle(fixture.debugElement.query(By.css('.' + CSS_CLASS_INPUTGROUP_LABEL)).nativeElement, ':after').content;
34553459
expect(asterisk).toBe('"*"');
34563460
expect(inputGroupIsRequiredClass).toBeDefined();
3461+
expect(input.nativeElement.getAttribute('aria-required')).toMatch('true');
34573462
});
34583463

34593464
it('Should update validity state when programmatically setting errors on reactive form controls', fakeAsync(() => {

0 commit comments

Comments
 (0)