@@ -182,6 +182,24 @@ describe('MatButton', () => {
182182 expect ( buttonDebugElement . nativeElement . getAttribute ( 'disabled' ) )
183183 . toBeNull ( 'Expect no disabled' ) ;
184184 } ) ;
185+
186+ it ( 'should be able to set a custom tabindex' , ( ) => {
187+ let fixture = TestBed . createComponent ( TestApp ) ;
188+ let testComponent = fixture . debugElement . componentInstance ;
189+ let buttonElement = fixture . debugElement . query ( By . css ( 'a' ) ) . nativeElement ;
190+
191+ fixture . componentInstance . tabIndex = 3 ;
192+ fixture . detectChanges ( ) ;
193+
194+ expect ( buttonElement . getAttribute ( 'tabIndex' ) )
195+ . toBe ( '3' , 'Expected custom tabindex to be set' ) ;
196+
197+ testComponent . isDisabled = true ;
198+ fixture . detectChanges ( ) ;
199+
200+ expect ( buttonElement . getAttribute ( 'tabIndex' ) )
201+ . toBe ( '-1' , 'Expected custom tabindex to be overwritten when disabled.' ) ;
202+ } ) ;
185203 } ) ;
186204
187205 // Ripple tests.
@@ -244,11 +262,12 @@ describe('MatButton', () => {
244262@Component ( {
245263 selector : 'test-app' ,
246264 template : `
247- <button mat-button type="button" (click)="increment()"
265+ <button [tabIndex]="tabIndex" mat-button type="button" (click)="increment()"
248266 [disabled]="isDisabled" [color]="buttonColor" [disableRipple]="rippleDisabled">
249267 Go
250268 </button>
251- <a href="http://www.google.com" mat-button [disabled]="isDisabled" [color]="buttonColor">
269+ <a [tabIndex]="tabIndex" href="http://www.google.com" mat-button [disabled]="isDisabled"
270+ [color]="buttonColor">
252271 Link
253272 </a>
254273 <button mat-fab>Fab Button</button>
@@ -260,6 +279,7 @@ class TestApp {
260279 isDisabled : boolean = false ;
261280 rippleDisabled : boolean = false ;
262281 buttonColor : ThemePalette ;
282+ tabIndex : number ;
263283
264284 increment ( ) {
265285 this . clickCount ++ ;
0 commit comments