diff --git a/src/lib/form-field/form-field.html b/src/lib/form-field/form-field.html
index f5d6510eb74..9043cb556a6 100644
--- a/src/lib/form-field/form-field.html
+++ b/src/lib/form-field/form-field.html
@@ -41,7 +41,7 @@
*
+ *ngIf="!hideRequiredMarker && _control.required && !_control.disabled"> *
diff --git a/src/lib/input/input.spec.ts b/src/lib/input/input.spec.ts
index 7cf2c091bc9..a74de097c75 100644
--- a/src/lib/input/input.spec.ts
+++ b/src/lib/input/input.spec.ts
@@ -413,6 +413,18 @@ describe('MatInput without forms', () => {
expect(el.nativeElement.textContent).toMatch(/hello\s+\*/g);
}));
+ it('should hide the required star if input is disabled', () => {
+ const fixture = TestBed.createComponent(MatInputPlaceholderRequiredTestComponent);
+
+ fixture.componentInstance.disabled = true;
+ fixture.detectChanges();
+
+ const el = fixture.debugElement.query(By.css('label'));
+
+ expect(el).not.toBeNull();
+ expect(el.nativeElement.textContent).toMatch(/^hello$/);
+ });
+
it('should hide the required star from screen readers', fakeAsync(() => {
let fixture = TestBed.createComponent(MatInputPlaceholderRequiredTestComponent);
fixture.detectChanges();
@@ -1151,11 +1163,12 @@ class MatInputWithType {
@Component({
template: `
-
+
`
})
class MatInputPlaceholderRequiredTestComponent {
- hideRequiredMarker: boolean;
+ hideRequiredMarker: boolean = false;
+ disabled: boolean = false;
}
@Component({