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 @@ -1081,7 +1081,7 @@ describe('MatMdcInput with forms', () => {
1081
1081
expect ( describedBy ) . toBe ( errorIds ) ;
1082
1082
} ) ) ;
1083
1083
1084
- it ( 'should not set `aria-invalid` to true if the input is empty' , fakeAsync ( ( ) => {
1084
+ it ( 'should set `aria-invalid` to true if the input is empty' , fakeAsync ( ( ) => {
1085
1085
// Submit the form since it's the one that triggers the default error state matcher.
1086
1086
dispatchFakeEvent ( fixture . nativeElement . querySelector ( 'form' ) , 'submit' ) ;
1087
1087
fixture . detectChanges ( ) ;
@@ -1090,7 +1090,7 @@ describe('MatMdcInput with forms', () => {
1090
1090
expect ( testComponent . formControl . invalid ) . toBe ( true , 'Expected form control to be invalid' ) ;
1091
1091
expect ( inputEl . value ) . toBeFalsy ( ) ;
1092
1092
expect ( inputEl . getAttribute ( 'aria-invalid' ) )
1093
- . toBe ( 'false ' , 'Expected aria-invalid to be set to "false". ' ) ;
1093
+ . toBe ( 'true ' , 'Expected aria-invalid to be set to "true" ' ) ;
1094
1094
1095
1095
inputEl . value = 'not valid' ;
1096
1096
fixture . detectChanges ( ) ;
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ import {MatInput as BaseMatInput} from '@angular/material/input';
39
39
'[attr.readonly]' : 'readonly && !_isNativeSelect || null' ,
40
40
// Only mark the input as invalid for assistive technology if it has a value since the
41
41
// state usually overlaps with `aria-required` when the input is empty and can be redundant.
42
- '[attr.aria-invalid]' : 'errorState && !empty ' ,
42
+ '[attr.aria-invalid]' : '(empty && required) ? null : errorState ' ,
43
43
'[attr.aria-required]' : 'required' ,
44
44
} ,
45
45
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 @@ -83,7 +83,7 @@ const _MatInputBase = mixinErrorState(class {
83
83
'[attr.readonly]' : 'readonly && !_isNativeSelect || null' ,
84
84
// Only mark the input as invalid for assistive technology if it has a value since the
85
85
// state usually overlaps with `aria-required` when the input is empty and can be redundant.
86
- '[attr.aria-invalid]' : 'errorState && !empty ' ,
86
+ '[attr.aria-invalid]' : '(empty && required) ? null : errorState ' ,
87
87
'[attr.aria-required]' : 'required' ,
88
88
} ,
89
89
providers : [ { provide : MatFormFieldControl , useExisting : MatInput } ] ,
You can’t perform that action at this time.
0 commit comments