Skip to content

Commit 440af1d

Browse files
fix(notification): add aria label and description (#3145)
Signed-off-by: Akshat Patel <[email protected]> Co-authored-by: Akshat Patel <[email protected]>
1 parent 0378cdd commit 440af1d

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/notification/actionable-notification.component.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@ import { BaseNotification } from "./base-notification.component";
3131
</svg>
3232
<div class="cds--actionable-notification__text-wrapper">
3333
<div class="cds--actionable-notification__content">
34-
<div *ngIf="!notificationObj.template" cdsActionableTitle [innerHTML]="notificationObj.title"></div>
34+
<div
35+
cdsActionableTitle
36+
*ngIf="!notificationObj.template"
37+
[id]="notificationID"
38+
[innerHTML]="notificationObj.title">
39+
</div>
3540
<div *ngIf="!notificationObj.template" cdsActionableSubtitle>
3641
<span [innerHTML]="notificationObj.message"></span>
3742
<ng-container *ngFor="let link of notificationObj.links">
@@ -82,7 +87,8 @@ export class ActionableNotification extends BaseNotification {
8287
this._notificationObj = Object.assign({}, this.defaultNotificationObj, obj);
8388
}
8489

85-
@HostBinding("attr.id") notificationID = `notification-${ActionableNotification.notificationCount++}`;
90+
notificationID = `actionable-notification-${ActionableNotification.notificationCount++}`;
91+
@HostBinding("attr.aria-labelledBy") notificationLabel = this.notificationID;
8692
@HostBinding("class.cds--actionable-notification") notificationClass = true;
8793
@HostBinding("class.cds--actionable-notification--toast") get toastVariant() { return this.notificationObj.variant === "toast"; }
8894
@HostBinding("class.cds--actionable-notification--error") get isError() { return this.notificationObj.type === "error"; }

src/notification/notification.component.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ import { BaseNotification } from "./base-notification.component";
2626
class="cds--inline-notification__icon">
2727
</svg>
2828
<div class="cds--inline-notification__text-wrapper">
29-
<div *ngIf="!notificationObj.template" cdsNotificationTitle [innerHTML]="notificationObj.title"></div>
29+
<div
30+
cdsNotificationTitle
31+
*ngIf="!notificationObj.template"
32+
[innerHTML]="notificationObj.title"
33+
[id]="notificationID">
34+
</div>
3035
<div *ngIf="!notificationObj.template" cdsNotificationSubtitle>
3136
<span [innerHTML]="notificationObj.message"></span>
3237
</div>
@@ -62,7 +67,8 @@ export class Notification extends BaseNotification {
6267
this._notificationObj = Object.assign({}, this.defaultNotificationObj, obj);
6368
}
6469

65-
@HostBinding("attr.id") notificationID = `notification-${Notification.notificationCount++}`;
70+
notificationID = `notification-${Notification.notificationCount++}`;
71+
@HostBinding("attr.aria-labelledBy") notificationLabel = this.notificationID;
6672
@HostBinding("class.cds--inline-notification") notificationClass = true;
6773
@HostBinding("class.cds--inline-notification--error") get isError() { return this.notificationObj.type === "error"; }
6874
@HostBinding("class.cds--inline-notification--info") get isInfo() { return this.notificationObj.type === "info"; }

0 commit comments

Comments
 (0)