File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change 4141 < span
4242 class ="mat-placeholder-required mat-form-field-required-marker "
4343 aria-hidden ="true "
44- *ngIf ="!hideRequiredMarker && _control.required "> *</ span >
44+ *ngIf ="!hideRequiredMarker && _control.required && !_control.disabled "> *</ span >
4545 </ label >
4646 </ span >
4747 </ div >
Original file line number Diff line number Diff line change @@ -413,6 +413,18 @@ describe('MatInput without forms', () => {
413413 expect ( el . nativeElement . textContent ) . toMatch ( / h e l l o \s + \* / g) ;
414414 } ) ) ;
415415
416+ it ( 'should hide the required star if input is disabled' , ( ) => {
417+ const fixture = TestBed . createComponent ( MatInputPlaceholderRequiredTestComponent ) ;
418+
419+ fixture . componentInstance . disabled = true ;
420+ fixture . detectChanges ( ) ;
421+
422+ const el = fixture . debugElement . query ( By . css ( 'label' ) ) ;
423+
424+ expect ( el ) . not . toBeNull ( ) ;
425+ expect ( el . nativeElement . textContent ) . toMatch ( / ^ h e l l o $ / ) ;
426+ } ) ;
427+
416428 it ( 'should hide the required star from screen readers' , fakeAsync ( ( ) => {
417429 let fixture = TestBed . createComponent ( MatInputPlaceholderRequiredTestComponent ) ;
418430 fixture . detectChanges ( ) ;
@@ -1151,11 +1163,12 @@ class MatInputWithType {
11511163
11521164@Component ( {
11531165 template : `<mat-form-field [hideRequiredMarker]="hideRequiredMarker">
1154- <input matInput required placeholder="hello">
1166+ <input matInput required [disabled]="disabled" placeholder="hello">
11551167 </mat-form-field>`
11561168} )
11571169class MatInputPlaceholderRequiredTestComponent {
1158- hideRequiredMarker : boolean ;
1170+ hideRequiredMarker : boolean = false ;
1171+ disabled : boolean = false ;
11591172}
11601173
11611174@Component ( {
You can’t perform that action at this time.
0 commit comments