Skip to content

Commit

Permalink
fix(snackbar): dynamically update role and aria-relevant attributes
Browse files Browse the repository at this point in the history
The `role="status"` and `aria-relevant="additions"` attributes
should dynamically change based on the visibility of the snackbar
to ensure proper accessibility.
When the snackbar is displayed, these attributes should inform the
assistive technologies  to announce the content.
  • Loading branch information
Kiarokh authored and adrianschmidt committed Aug 7, 2024
1 parent 5926906 commit 209052f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/components/snackbar/snackbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,11 @@ export class Snackbar {
'is-closing': this.closing,
}}
id={this.snackbarId}
role={this.open ? 'status' : undefined}
aria-relevant={this.open ? 'additions' : undefined}
>
<div class="surface" role="status" aria-relevant="additions">
<div class="label" aria-atomic="false">
{this.message}
</div>
<div class="surface" aria-atomic="false">
<div class="label">{this.message}</div>
{this.renderActions(this.actionText)}
{this.renderDismissButton(this.dismissible)}
</div>
Expand Down

0 comments on commit 209052f

Please sign in to comment.