Skip to content
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

fix(toast): adding alert role for toast #492

Merged
merged 6 commits into from
Aug 30, 2022
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Fixed
- Chip - made remove button accessible with the keyboard [#480](https://github.com/IgniteUI/igniteui-webcomponents/issues/480)
- Toast - added `role="alert"` to the message container for assistive software to read it without the need of focusing [#479](https://github.com/IgniteUI/igniteui-webcomponents/issues/479)

## [3.3.1] - 2022-08-10
### Changed
Expand Down
8 changes: 3 additions & 5 deletions src/components/toast/toast.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,19 @@ describe('Toast', () => {
toast.setAttribute('display-time', `10000`);
await elementUpdated(toast);
expect(toast.displayTime).to.eq(10000);
expect(toast).dom.to.equal(
`<igc-toast display-time='10000'></igc-toast>`
);
expect(toast).dom.to.have.attribute('display-time', '10000');
});

it('should change the toast keepOpen option correctly.', async () => {
toast.keepOpen = true;
expect(toast.keepOpen).to.be.true;
await elementUpdated(toast);
expect(toast).dom.to.equal(`<igc-toast keep-open></igc-toast>`);
expect(toast).dom.to.have.attribute('keep-open');

toast.keepOpen = false;
expect(toast.keepOpen).to.be.false;
await elementUpdated(toast);
expect(toast).dom.to.equal(`<igc-toast></igc-toast>`);
expect(toast).dom.to.not.have.attribute('keep-open');
});

it('show method should open the toast', async () => {
Expand Down
10 changes: 10 additions & 0 deletions src/components/toast/toast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ export default class IgcToastComponent extends LitElement {
}
}

public override connectedCallback() {
super.connectedCallback();
if (!this.hasAttribute('role')) {
this.setAttribute('role', 'alert');
}
if (!this.hasAttribute('aria-live')) {
this.setAttribute('aria-live', 'polite');
}
}

protected override render() {
return html`<slot></slot>`;
}
Expand Down