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(slide-toggle): label not being read out by screen reader on IE #14259

Merged
merged 1 commit into from
Nov 27, 2018
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
3 changes: 1 addition & 2 deletions src/lib/slide-toggle/slide-toggle.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<label class="mat-slide-toggle-label" #label>

<label [attr.for]="inputId" class="mat-slide-toggle-label" #label>
<div #toggleBar class="mat-slide-toggle-bar"
[class.mat-slide-toggle-bar-no-side-margin]="!labelContent.textContent || !labelContent.textContent.trim()">

Expand Down
6 changes: 6 additions & 0 deletions src/lib/slide-toggle/slide-toggle.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,12 @@ describe('MatSlideToggle without forms', () => {
expect(inputElement.hasAttribute('aria-labelledby')).toBeFalsy();
});

it('should set the `for` attribute to the id of the input element', () => {
expect(labelElement.getAttribute('for')).toBeTruthy();
expect(inputElement.getAttribute('id')).toBeTruthy();
expect(labelElement.getAttribute('for')).toBe(inputElement.getAttribute('id'));
});

it('should emit the new values properly', fakeAsync(() => {
labelElement.click();
fixture.detectChanges();
Expand Down