Skip to content

Commit

Permalink
fix(input): required asterisk being read out by screen readers (angul…
Browse files Browse the repository at this point in the history
…ar#6277)

Fixes the asterisk that gets added after a required input being read out by screen readers.
  • Loading branch information
crisbeto authored and tinayuangao committed Aug 4, 2017
1 parent 3df4d72 commit 0850981
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/lib/input/input-container.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
*ngIf="_hasPlaceholder()">
<ng-content select="md-placeholder, mat-placeholder"></ng-content>
{{_mdInputChild.placeholder}}
<span class="mat-placeholder-required" *ngIf="!hideRequiredMarker && _mdInputChild.required">*</span>
<span
class="mat-placeholder-required"
aria-hidden="true"
*ngIf="!hideRequiredMarker && _mdInputChild.required">*</span>
</label>
</span>
</div>
Expand Down
9 changes: 9 additions & 0 deletions src/lib/input/input-container.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,15 @@ describe('MdInputContainer without forms', function () {
expect(el.nativeElement.textContent).toMatch(/hello\s+\*/g);
});

it('should hide the required star from screen readers', () => {
let fixture = TestBed.createComponent(MdInputContainerPlaceholderRequiredTestComponent);
fixture.detectChanges();

let el = fixture.debugElement.query(By.css('.mat-placeholder-required')).nativeElement;

expect(el.getAttribute('aria-hidden')).toBe('true');
});

it('hide placeholder required star when set to hide the required marker', () => {
let fixture = TestBed.createComponent(MdInputContainerPlaceholderRequiredTestComponent);
fixture.detectChanges();
Expand Down

0 comments on commit 0850981

Please sign in to comment.