Skip to content

Commit

Permalink
fix: set role on host and use 'off' value for aria-live
Browse files Browse the repository at this point in the history
  • Loading branch information
dauriamarco committed Feb 8, 2024
1 parent 2af9a1a commit 75fb66d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/components/notification/notification.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ const meta: Meta = {
<div
class="notification-container"
style="display: flex; flex-direction: column;"
aria-live="polite"
aria-live="off"
>
${story()}
</div>
Expand Down
4 changes: 1 addition & 3 deletions src/components/notification/notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export class SbbNotificationElement extends LitElement {

public override connectedCallback(): void {
super.connectedCallback();
this.setAttribute('role', this.getAttribute('role') ?? 'status');
this._setInlineLinks();
}

Expand All @@ -141,9 +142,6 @@ export class SbbNotificationElement extends LitElement {
await this.updateComplete;
this._setNotificationHeight();
this._open();
this.shadowRoot
?.querySelector<SbbNotificationElement>('.sbb-notification')!
.setAttribute('role', this.getAttribute('role') ?? 'status');
}

public override disconnectedCallback(): void {
Expand Down
4 changes: 2 additions & 2 deletions src/components/notification/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ This role signifies that the notification provides information about the current

Consumers can override the role's default value by setting it on the component;
moreover, to announce the notification's content to screen readers as it becomes visible,
consumers **must** use the `aria-live` attribute with at least `polite` value on the component's container.
consumers **must** use the `aria-live` attribute with the `off` value on the component's container.
This ensures that users who rely on screen readers are promptly informed of any relevant updates or changes.

```html
<!-- Add here any incoming notification by adding a sbb-notification component. -->
<div id="notification-container" aria-live="polite">
<div id="notification-container" aria-live="off">
<sbb-notification type="success">Task successfully completed.</sbb-notification>
</div>
```
Expand Down

0 comments on commit 75fb66d

Please sign in to comment.