Skip to content

feat(icon): add aria-hidden="true" attribute by default + test - 20.0.x #16010

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: 20.0.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 @@ -16,7 +16,7 @@
</ng-template>

<ng-template #defIcon>
<igx-icon family="default" name="date_range" [attr.aria-hidden]="true"></igx-icon>
<igx-icon family="default" name="date_range"></igx-icon>
</ng-template>

<ng-template #defDateSeparatorTemplate>{{ dateSeparator }}</ng-template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
@if (!iconTemplate) {
<igx-icon
family="default"
[name]="panel.collapsed ? 'expand' : 'collapse'"
[attr.aria-hidden]="true">
[name]="panel.collapsed ? 'expand' : 'collapse'">
</igx-icon>
}
</div>
Expand Down
14 changes: 13 additions & 1 deletion projects/igniteui-angular/src/lib/icon/icon.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,23 @@ describe("Icon", () => {
el = debugElement.nativeElement;
});

it("should instatiate with defaults", () => {
it("should instantiate with defaults", () => {
fixture.detectChanges();

expect(instance.getFamily).toBe("material");
expect(instance.getActive).toBe(true);
expect(instance.ariaHidden).toBe(true);
});

it("should be able to set the aria-hidden attribute", () => {
fixture.detectChanges();

expect(el.getAttribute('aria-hidden')).toBe("true");

instance.ariaHidden = false;
fixture.detectChanges();

expect(el.getAttribute('aria-hidden')).toBe("false");
});

it("should set icon as inactive", () => {
Expand Down
8 changes: 8 additions & 0 deletions projects/igniteui-angular/src/lib/icon/icon.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ export class IgxIconComponent implements OnInit, OnChanges, OnDestroy {
return !this.active;
}

/**
* The `aria-hidden` attribute of the icon.
* By default is set to 'true'.
*/
@HostBinding("attr.aria-hidden")
@Input()
public ariaHidden = true;

/**
* An @Input property that sets the value of the `family`. By default it's "material".
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<ng-container *ngTemplateOutlet="toggleIconTemplate; context: {$implicit: this.collapsed}"></ng-container>
}
@if (!toggleIconTemplate) {
<igx-icon family="default" [name]="toggleIcon" [attr.aria-hidden]="true"></igx-icon>
<igx-icon family="default" [name]="toggleIcon"></igx-icon>
}
</igx-suffix>
<ng-container ngProjectAs="igx-hint, [igxHint]" >
Expand Down
Loading