fix(input): required asterisk being read out by screen readers (#6277)

Fixes the asterisk that gets added after a required input being read out by screen readers.
This commit is contained in:
Kristiyan Kostadinov
2017-08-05 01:09:42 +02:00
committed by tinayuangao
parent 3df4d72c28
commit 08509816b2
2 changed files with 13 additions and 1 deletions
+4 -1
View File
@@ -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>
+9
View File
@@ -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();