File tree Expand file tree Collapse file tree 4 files changed +34
-3
lines changed Expand file tree Collapse file tree 4 files changed +34
-3
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,15 @@ export const MAT_SUFFIX = new InjectionToken<MatSuffix>('MatSuffix');
23
23
export class MatSuffix {
24
24
_isText = false ;
25
25
26
- constructor ( elementRef : ElementRef ) {
26
+ constructor ( private elementRef : ElementRef < HTMLElement > ) {
27
27
this . _isText = elementRef . nativeElement . hasAttribute ( 'matTextSuffix' ) ;
28
28
}
29
+
30
+ disable ( ) : void {
31
+ this . elementRef . nativeElement . classList . add ( 'mat-form-field-suffix--disabled' ) ;
32
+ }
33
+
34
+ enable ( ) : void {
35
+ this . elementRef . nativeElement . classList . remove ( 'mat-form-field-suffix--disabled' ) ;
36
+ }
29
37
}
Original file line number Diff line number Diff line change @@ -167,6 +167,9 @@ export class MatInput
167
167
}
168
168
set disabled ( value : BooleanInput ) {
169
169
this . _disabled = coerceBooleanProperty ( value ) ;
170
+ this . _formField ?. _suffixChildren ?. forEach ( suffix =>
171
+ this . _disabled ? suffix . disable ( ) : suffix . enable ( ) ,
172
+ ) ;
170
173
171
174
// Browsers may not fire the blur event if the input is disabled too quickly.
172
175
// Reset from here to ensure that the element doesn't become stuck.
@@ -332,6 +335,12 @@ export class MatInput
332
335
this . stateChanges . next ( ) ;
333
336
} ) ;
334
337
}
338
+
339
+ if ( this . _disabled ) {
340
+ this . _formField ?. _suffixChildren . forEach ( suffix => {
341
+ suffix . disable ( ) ;
342
+ } ) ;
343
+ }
335
344
}
336
345
337
346
ngOnChanges ( ) {
Original file line number Diff line number Diff line change 6
6
* found in the LICENSE file at https://angular.io/license
7
7
*/
8
8
9
- import { Directive } from '@angular/core' ;
9
+ import { Directive , ElementRef } from '@angular/core' ;
10
10
import { MAT_SUFFIX } from '@angular/material/form-field' ;
11
11
12
12
/** Suffix to be placed at the end of the form field. */
13
13
@Directive ( {
14
14
selector : '[matSuffix]' ,
15
15
providers : [ { provide : MAT_SUFFIX , useExisting : MatLegacySuffix } ] ,
16
16
} )
17
- export class MatLegacySuffix { }
17
+ export class MatLegacySuffix {
18
+ constructor ( private elementRef : ElementRef < HTMLElement > ) { }
19
+
20
+ disable ( ) : void {
21
+ this . elementRef . nativeElement . classList . add ( 'mat-form-field-suffix--disabled' ) ;
22
+ }
23
+
24
+ enable ( ) : void {
25
+ this . elementRef . nativeElement . classList . remove ( 'mat-form-field-suffix--disabled' ) ;
26
+ }
27
+ }
Original file line number Diff line number Diff line change 53
53
caret-color : theming .get-color-from-palette ($accent , text );
54
54
}
55
55
56
+ .mat-form-field-suffix--disabled {
57
+ color : theming .get-color-from-palette ($foreground , disabled-text );
58
+ }
59
+
56
60
.mat-form-field.mat-warn .mat-input-element ,
57
61
.mat-form-field-invalid .mat-input-element {
58
62
caret-color : theming .get-color-from-palette ($warn , text );
You can’t perform that action at this time.
0 commit comments