Skip to content

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

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
Original file line number Diff line number Diff line change
Expand Up @@ -231,19 +231,24 @@ describe('IgxDatePicker', () => {

expect(datePicker).toBeDefined();
expect(inputGroup.isRequired).toBeTruthy();
expect((datePicker as any).inputDirective.nativeElement.getAttribute('aria-required')).toEqual('true');
});

it('should update inputGroup isRequired correctly', () => {
it('should update inputGroup isRequired correctly', fakeAsync(() => {
const inputGroup = (datePicker as any).inputGroup;
const inputEl = (datePicker as any).inputDirective.nativeElement;

expect(datePicker).toBeDefined();
expect(inputGroup.isRequired).toBeTruthy();
expect(inputEl.getAttribute('aria-required')).toEqual('true');

(fixture.componentInstance as IgxDatePickerNgModelComponent).isRequired = false;
fixture.detectChanges();
tick();

expect(inputGroup.isRequired).toBeFalsy();
});
expect(inputEl.getAttribute('aria-required')).toEqual('false');
}));

it('should set validity to initial when the form is reset', fakeAsync(() => {
fixture = TestBed.createComponent(IgxDatePickerInFormComponent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,8 @@ export class IgxDatePickerComponent extends PickerBaseDirective implements Contr
this._ngControl.statusChanges.subscribe(this.onStatusChanged.bind(this));
if (this._ngControl.control.validator) {
this.inputGroup.isRequired = this.required;
this._renderer.setAttribute(this.inputDirective.nativeElement, 'aria-required',
(this.required || false).toString());
this.cdr.detectChanges();
}
}
Expand Down Expand Up @@ -862,6 +864,8 @@ export class IgxDatePickerComponent extends PickerBaseDirective implements Contr
this.disabled = this._ngControl.disabled;
this.updateValidity();
this.inputGroup.isRequired = this.required;
this._renderer.setAttribute(this.inputDirective.nativeElement, 'aria-required',
(this.required || false).toString());
};

private handleSelection(date: Date): void {
Expand Down
Loading