File tree 2 files changed +20
-1
lines changed
2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,8 @@ describe('MatRadio', () => {
18
18
RadioGroupWithFormControl ,
19
19
StandaloneRadioButtons ,
20
20
InterleavedRadioGroup ,
21
- TranscludingWrapper
21
+ TranscludingWrapper ,
22
+ RadioButtonWithPredefinedTabindex ,
22
23
]
23
24
} ) ;
24
25
@@ -714,6 +715,17 @@ describe('MatRadio', () => {
714
715
expect ( radioButtonInput . tabIndex )
715
716
. toBe ( 4 , 'Expected the tabindex to be set to "4".' ) ;
716
717
} ) ;
718
+
719
+ it ( 'should remove the tabindex from the host element' , ( ) => {
720
+ const predefinedFixture = TestBed . createComponent ( RadioButtonWithPredefinedTabindex ) ;
721
+ predefinedFixture . detectChanges ( ) ;
722
+
723
+ const radioButtonEl =
724
+ predefinedFixture . debugElement . query ( By . css ( '.mat-radio-button' ) ) . nativeElement ;
725
+
726
+ expect ( radioButtonEl . getAttribute ( 'tabindex' ) ) . toBeFalsy ( ) ;
727
+ } ) ;
728
+
717
729
} ) ;
718
730
719
731
describe ( 'group interspersed with other tags' , ( ) => {
@@ -873,3 +885,9 @@ class InterleavedRadioGroup {
873
885
`
874
886
} )
875
887
class TranscludingWrapper { }
888
+
889
+
890
+ @Component ( {
891
+ template : `<mat-radio-button tabindex="0"></mat-radio-button>`
892
+ } )
893
+ class RadioButtonWithPredefinedTabindex { }
Original file line number Diff line number Diff line change @@ -336,6 +336,7 @@ export const _MatRadioButtonMixinBase:
336
336
'[class.mat-radio-checked]' : 'checked' ,
337
337
'[class.mat-radio-disabled]' : 'disabled' ,
338
338
'[class._mat-animation-noopable]' : '_animationMode === "NoopAnimations"' ,
339
+ '[attr.tabindex]' : 'null' ,
339
340
'[attr.id]' : 'id' ,
340
341
// Note: under normal conditions focus shouldn't land on this element, however it may be
341
342
// programmatically set, for example inside of a focus trap, in this case we want to forward
You can’t perform that action at this time.
0 commit comments