@@ -444,6 +444,28 @@ describe('MDC-based MatCheckbox', () => {
444
444
expect ( checkboxNativeElement . querySelector ( 'svg' ) ! . getAttribute ( 'focusable' ) ) . toBe ( 'false' ) ;
445
445
} ) ) ;
446
446
447
+ it ( 'should be able to mark a checkbox as disabled while keeping it interactive' , fakeAsync ( ( ) => {
448
+ testComponent . isDisabled = true ;
449
+ fixture . changeDetectorRef . markForCheck ( ) ;
450
+ fixture . detectChanges ( ) ;
451
+
452
+ expect ( checkboxNativeElement . classList ) . not . toContain (
453
+ 'mat-mdc-checkbox-disabled-interactive' ,
454
+ ) ;
455
+ expect ( inputElement . hasAttribute ( 'aria-disabled' ) ) . toBe ( false ) ;
456
+ expect ( inputElement . tabIndex ) . toBe ( - 1 ) ;
457
+ expect ( inputElement . disabled ) . toBe ( true ) ;
458
+
459
+ testComponent . disabledInteractive = true ;
460
+ fixture . changeDetectorRef . markForCheck ( ) ;
461
+ fixture . detectChanges ( ) ;
462
+
463
+ expect ( checkboxNativeElement . classList ) . toContain ( 'mat-mdc-checkbox-disabled-interactive' ) ;
464
+ expect ( inputElement . getAttribute ( 'aria-disabled' ) ) . toBe ( 'true' ) ;
465
+ expect ( inputElement . tabIndex ) . toBe ( 0 ) ;
466
+ expect ( inputElement . disabled ) . toBe ( false ) ;
467
+ } ) ) ;
468
+
447
469
describe ( 'ripple elements' , ( ) => {
448
470
it ( 'should show ripples on label mousedown' , fakeAsync ( ( ) => {
449
471
const rippleSelector = '.mat-ripple-element:not(.mat-checkbox-persistent-ripple)' ;
@@ -1111,6 +1133,7 @@ describe('MatCheckboxDefaultOptions', () => {
1111
1133
[color]="checkboxColor"
1112
1134
[disableRipple]="disableRipple"
1113
1135
[value]="checkboxValue"
1136
+ [disabledInteractive]="disabledInteractive"
1114
1137
(change)="onCheckboxChange($event)">
1115
1138
Simple checkbox
1116
1139
</mat-checkbox>
@@ -1120,13 +1143,14 @@ describe('MatCheckboxDefaultOptions', () => {
1120
1143
} )
1121
1144
class SingleCheckbox {
1122
1145
labelPos : 'before' | 'after' = 'after' ;
1123
- isChecked : boolean = false ;
1124
- isRequired : boolean = false ;
1125
- isIndeterminate : boolean = false ;
1126
- isDisabled : boolean = false ;
1127
- disableRipple : boolean = false ;
1128
- parentElementClicked : boolean = false ;
1129
- parentElementKeyedUp : boolean = false ;
1146
+ isChecked = false ;
1147
+ isRequired = false ;
1148
+ isIndeterminate = false ;
1149
+ isDisabled = false ;
1150
+ disableRipple = false ;
1151
+ parentElementClicked = false ;
1152
+ parentElementKeyedUp = false ;
1153
+ disabledInteractive = false ;
1130
1154
checkboxId : string | null = 'simple-check' ;
1131
1155
checkboxColor : ThemePalette = 'primary' ;
1132
1156
checkboxValue : string = 'single_checkbox' ;
@@ -1143,9 +1167,9 @@ class SingleCheckbox {
1143
1167
imports : [ MatCheckbox , FormsModule ] ,
1144
1168
} )
1145
1169
class CheckboxWithNgModel {
1146
- isGood : boolean = false ;
1147
- isRequired : boolean = true ;
1148
- isDisabled : boolean = false ;
1170
+ isGood = false ;
1171
+ isRequired = true ;
1172
+ isDisabled = false ;
1149
1173
}
1150
1174
1151
1175
@Component ( {
0 commit comments