File tree 4 files changed +6
-6
lines changed
material-experimental/mdc-input 4 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -1070,7 +1070,7 @@ describe('MatMdcInput with forms', () => {
1070
1070
expect ( describedBy ) . toBe ( errorIds ) ;
1071
1071
} ) ) ;
1072
1072
1073
- it ( 'should not set `aria-invalid` to true if the input is empty' , fakeAsync ( ( ) => {
1073
+ it ( 'should set `aria-invalid` to true if the input is empty' , fakeAsync ( ( ) => {
1074
1074
// Submit the form since it's the one that triggers the default error state matcher.
1075
1075
dispatchFakeEvent ( fixture . nativeElement . querySelector ( 'form' ) , 'submit' ) ;
1076
1076
fixture . detectChanges ( ) ;
@@ -1079,7 +1079,7 @@ describe('MatMdcInput with forms', () => {
1079
1079
expect ( testComponent . formControl . invalid ) . toBe ( true , 'Expected form control to be invalid' ) ;
1080
1080
expect ( inputEl . value ) . toBeFalsy ( ) ;
1081
1081
expect ( inputEl . getAttribute ( 'aria-invalid' ) )
1082
- . toBe ( 'false ' , 'Expected aria-invalid to be set to "false". ' ) ;
1082
+ . toBe ( 'true ' , 'Expected aria-invalid to be set to "true" ' ) ;
1083
1083
1084
1084
inputEl . value = 'not valid' ;
1085
1085
fixture . detectChanges ( ) ;
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ import {MatInput as BaseMatInput} from '@angular/material/input';
35
35
'[attr.readonly]' : 'readonly && !_isNativeSelect || null' ,
36
36
// Only mark the input as invalid for assistive technology if it has a value since the
37
37
// state usually overlaps with `aria-required` when the input is empty and can be redundant.
38
- '[attr.aria-invalid]' : 'errorState && !empty ' ,
38
+ '[attr.aria-invalid]' : '(empty && required) ? null : errorState ' ,
39
39
'[attr.aria-required]' : 'required' ,
40
40
} ,
41
41
providers : [ { provide : MatFormFieldControl , useExisting : MatInput } ] ,
Original file line number Diff line number Diff line change @@ -1219,7 +1219,7 @@ describe('MatInput with forms', () => {
1219
1219
expect ( describedBy ) . toBe ( errorIds ) ;
1220
1220
} ) ) ;
1221
1221
1222
- it ( 'should not set `aria-invalid` to true if the input is empty' , fakeAsync ( ( ) => {
1222
+ it ( 'should set `aria-invalid` to true if the input is empty' , fakeAsync ( ( ) => {
1223
1223
// Submit the form since it's the one that triggers the default error state matcher.
1224
1224
dispatchFakeEvent ( fixture . nativeElement . querySelector ( 'form' ) , 'submit' ) ;
1225
1225
fixture . detectChanges ( ) ;
@@ -1228,7 +1228,7 @@ describe('MatInput with forms', () => {
1228
1228
expect ( testComponent . formControl . invalid ) . toBe ( true , 'Expected form control to be invalid' ) ;
1229
1229
expect ( inputEl . value ) . toBeFalsy ( ) ;
1230
1230
expect ( inputEl . getAttribute ( 'aria-invalid' ) )
1231
- . toBe ( 'false ' , 'Expected aria-invalid to be set to "false ".' ) ;
1231
+ . toBe ( 'true ' , 'Expected aria-invalid to be set to "true ".' ) ;
1232
1232
1233
1233
inputEl . value = 'not valid' ;
1234
1234
fixture . detectChanges ( ) ;
Original file line number Diff line number Diff line change @@ -86,7 +86,7 @@ const _MatInputMixinBase: CanUpdateErrorStateCtor & typeof MatInputBase =
86
86
'[attr.readonly]' : 'readonly && !_isNativeSelect || null' ,
87
87
// Only mark the input as invalid for assistive technology if it has a value since the
88
88
// state usually overlaps with `aria-required` when the input is empty and can be redundant.
89
- '[attr.aria-invalid]' : 'errorState && !empty ' ,
89
+ '[attr.aria-invalid]' : '(empty && required) ? null : errorState ' ,
90
90
'[attr.aria-required]' : 'required' ,
91
91
} ,
92
92
providers : [ { provide : MatFormFieldControl , useExisting : MatInput } ] ,
You can’t perform that action at this time.
0 commit comments