Skip to content

Sync aria-required with required state - 19.2.x #16001

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: 19.2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions projects/igniteui-angular/src/lib/combo/combo.common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1322,6 +1322,7 @@ export abstract class IgxComboBaseDirective implements IgxComboBase, AfterViewCh
protected manageRequiredAsterisk(): void {
if (this.ngControl) {
this.inputGroup.isRequired = this.required;
this.comboInput.nativeElement.setAttribute('aria-required', this.required.toString());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3390,8 +3390,10 @@ describe('igxCombo', () => {
it('should add/remove asterisk when setting validators dynamically', () => {
let inputGroupIsRequiredClass = fixture.debugElement.query(By.css('.' + CSS_CLASS_INPUTGROUP_REQUIRED));
let asterisk = window.getComputedStyle(fixture.debugElement.query(By.css('.' + CSS_CLASS_INPUTGROUP_LABEL)).nativeElement, ':after').content;
input = fixture.debugElement.query(By.css(`.${CSS_CLASS_COMBO_INPUTGROUP}`));
expect(asterisk).toBe('"*"');
expect(inputGroupIsRequiredClass).toBeDefined();
expect(input.nativeElement.getAttribute('aria-required')).toMatch('true');

fixture.componentInstance.reactiveForm.controls.townCombo.clearValidators();
fixture.componentInstance.reactiveForm.controls.townCombo.updateValueAndValidity();
Expand All @@ -3400,6 +3402,7 @@ describe('igxCombo', () => {
asterisk = window.getComputedStyle(fixture.debugElement.query(By.css('.' + CSS_CLASS_INPUTGROUP_LABEL)).nativeElement, ':after').content;
expect(asterisk).toBe('none');
expect(inputGroupIsRequiredClass).toBeNull();
expect(input.nativeElement.getAttribute('aria-required')).toMatch('false');

fixture.componentInstance.reactiveForm.controls.townCombo.setValidators(Validators.required);
fixture.componentInstance.reactiveForm.controls.townCombo.updateValueAndValidity();
Expand All @@ -3408,6 +3411,7 @@ describe('igxCombo', () => {
asterisk = window.getComputedStyle(fixture.debugElement.query(By.css('.' + CSS_CLASS_INPUTGROUP_LABEL)).nativeElement, ':after').content;
expect(asterisk).toBe('"*"');
expect(inputGroupIsRequiredClass).toBeDefined();
expect(input.nativeElement.getAttribute('aria-required')).toMatch('true');
});

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