@@ -132,6 +132,29 @@ describe('MDC-based MatRadio', () => {
132132 }
133133 } ) ;
134134
135+ it ( 'should make all disabled buttons interactive if the group is marked as disabledInteractive' , ( ) => {
136+ testComponent . isGroupDisabledInteractive = true ;
137+ fixture . changeDetectorRef . markForCheck ( ) ;
138+ fixture . detectChanges ( ) ;
139+ expect ( radioInstances . every ( radio => radio . disabledInteractive ) ) . toBe ( true ) ;
140+ } ) ;
141+
142+ it ( 'should prevent the click action when disabledInteractive and disabled' , ( ) => {
143+ testComponent . isGroupDisabled = true ;
144+ testComponent . isGroupDisabledInteractive = true ;
145+ fixture . changeDetectorRef . markForCheck ( ) ;
146+ fixture . detectChanges ( ) ;
147+
148+ // We can't monitor the `defaultPrevented` state on the
149+ // native `click` so we dispatch an extra one.
150+ const fakeEvent = dispatchFakeEvent ( radioInputElements [ 0 ] , 'click' ) ;
151+ radioInputElements [ 0 ] . click ( ) ;
152+ fixture . detectChanges ( ) ;
153+
154+ expect ( fakeEvent . defaultPrevented ) . toBe ( true ) ;
155+ expect ( radioInstances [ 0 ] . checked ) . toBe ( false ) ;
156+ } ) ;
157+
135158 it ( 'should set required to each radio button when the group is required' , ( ) => {
136159 testComponent . isGroupRequired = true ;
137160 fixture . changeDetectorRef . markForCheck ( ) ;
@@ -675,6 +698,7 @@ describe('MDC-based MatRadio', () => {
675698 let fixture : ComponentFixture < DisableableRadioButton > ;
676699 let radioInstance : MatRadioButton ;
677700 let radioNativeElement : HTMLInputElement ;
701+ let radioHost : HTMLElement ;
678702 let testComponent : DisableableRadioButton ;
679703
680704 beforeEach ( ( ) => {
@@ -683,8 +707,9 @@ describe('MDC-based MatRadio', () => {
683707
684708 testComponent = fixture . debugElement . componentInstance ;
685709 const radioDebugElement = fixture . debugElement . query ( By . directive ( MatRadioButton ) ) ! ;
710+ radioHost = radioDebugElement . nativeElement ;
686711 radioInstance = radioDebugElement . injector . get < MatRadioButton > ( MatRadioButton ) ;
687- radioNativeElement = radioDebugElement . nativeElement . querySelector ( 'input' ) ;
712+ radioNativeElement = radioHost . querySelector ( 'input' ) ! ;
688713 } ) ;
689714
690715 it ( 'should toggle the disabled state' , ( ) => {
@@ -703,6 +728,24 @@ describe('MDC-based MatRadio', () => {
703728 expect ( radioInstance . disabled ) . toBeFalsy ( ) ;
704729 expect ( radioNativeElement . disabled ) . toBeFalsy ( ) ;
705730 } ) ;
731+
732+ it ( 'should keep the button interactive if disabledInteractive is enabled' , ( ) => {
733+ testComponent . disabled = true ;
734+ fixture . changeDetectorRef . markForCheck ( ) ;
735+ fixture . detectChanges ( ) ;
736+
737+ expect ( radioNativeElement . disabled ) . toBe ( true ) ;
738+ expect ( radioNativeElement . hasAttribute ( 'aria-disabled' ) ) . toBe ( false ) ;
739+ expect ( radioHost . classList ) . not . toContain ( 'mat-mdc-radio-disabled-interactive' ) ;
740+
741+ testComponent . disabledInteractive = true ;
742+ fixture . changeDetectorRef . markForCheck ( ) ;
743+ fixture . detectChanges ( ) ;
744+
745+ expect ( radioNativeElement . disabled ) . toBe ( false ) ;
746+ expect ( radioNativeElement . getAttribute ( 'aria-disabled' ) ) . toBe ( 'true' ) ;
747+ expect ( radioHost . classList ) . toContain ( 'mat-mdc-radio-disabled-interactive' ) ;
748+ } ) ;
706749 } ) ;
707750
708751 describe ( 'as standalone' , ( ) => {
@@ -1031,11 +1074,13 @@ describe('MatRadioDefaultOverrides', () => {
10311074
10321075@Component ( {
10331076 template : `
1034- <mat-radio-group [disabled]="isGroupDisabled"
1035- [labelPosition]="labelPos"
1036- [required]="isGroupRequired"
1037- [value]="groupValue"
1038- name="test-name">
1077+ <mat-radio-group
1078+ [disabled]="isGroupDisabled"
1079+ [labelPosition]="labelPos"
1080+ [required]="isGroupRequired"
1081+ [value]="groupValue"
1082+ [disabledInteractive]="isGroupDisabledInteractive"
1083+ name="test-name">
10391084 @if (isFirstShown) {
10401085 <mat-radio-button value="fire" [disableRipple]="disableRipple" [disabled]="isFirstDisabled"
10411086 [color]="color">
@@ -1058,6 +1103,7 @@ class RadiosInsideRadioGroup {
10581103 isFirstDisabled = false ;
10591104 isGroupDisabled = false ;
10601105 isGroupRequired = false ;
1106+ isGroupDisabledInteractive = false ;
10611107 groupValue : string | null = null ;
10621108 disableRipple = false ;
10631109 color : string | null ;
@@ -1130,16 +1176,18 @@ class RadioGroupWithNgModel {
11301176}
11311177
11321178@Component ( {
1133- template : `<mat-radio-button>One</mat-radio-button>` ,
1179+ template : `
1180+ <mat-radio-button
1181+ [disabled]="disabled"
1182+ [disabledInteractive]="disabledInteractive">One</mat-radio-button>` ,
11341183 standalone : true ,
11351184 imports : [ MatRadioModule , FormsModule , ReactiveFormsModule , CommonModule ] ,
11361185} )
11371186class DisableableRadioButton {
1138- @ViewChild ( MatRadioButton ) matRadioButton : MatRadioButton ;
1187+ disabled = false ;
1188+ disabledInteractive = false ;
11391189
1140- set disabled ( value : boolean ) {
1141- this . matRadioButton . disabled = value ;
1142- }
1190+ @ViewChild ( MatRadioButton ) matRadioButton : MatRadioButton ;
11431191}
11441192
11451193@Component ( {
0 commit comments