Skip to content

Commit

Permalink
fix(snackbar): improve accessibility of the dismiss button
Browse files Browse the repository at this point in the history
  • Loading branch information
Kiarokh authored and adrianschmidt committed Aug 7, 2024
1 parent 730c14a commit 5926906
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/components/snackbar/snackbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
} from '@stencil/core';
import translate from '../../global/translations';
import { SnackbarContainer } from './container';
import { createRandomString } from 'src/util/random-string';

const container = new SnackbarContainer();
const hideAnimationDuration = 300;
Expand Down Expand Up @@ -112,8 +113,13 @@ export class Snackbar {
@State()
private closing: boolean = true;

private snackbarId: string;
private timeoutId?: number;

public constructor() {
this.snackbarId = createRandomString();
}

@Listen('changeOffset')
protected onChangeIndex(event: CustomEvent<number>) {
event.stopPropagation();
Expand Down Expand Up @@ -173,6 +179,7 @@ export class Snackbar {
open: this.open,
'is-closing': this.closing,
}}
id={this.snackbarId}
>
<div class="surface" role="status" aria-relevant="additions">
<div class="label" aria-atomic="false">
Expand Down Expand Up @@ -226,6 +233,7 @@ export class Snackbar {
icon="multiply"
label={label}
onClick={this.close}
aria-controls={this.snackbarId}
/>
</div>
);
Expand Down

0 comments on commit 5926906

Please sign in to comment.