@@ -182,6 +182,24 @@ describe('MatButton', () => {
182
182
expect ( buttonDebugElement . nativeElement . getAttribute ( 'disabled' ) )
183
183
. toBeNull ( 'Expect no disabled' ) ;
184
184
} ) ;
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
+ } ) ;
185
203
} ) ;
186
204
187
205
// Ripple tests.
@@ -244,11 +262,12 @@ describe('MatButton', () => {
244
262
@Component ( {
245
263
selector : 'test-app' ,
246
264
template : `
247
- <button mat-button type="button" (click)="increment()"
265
+ <button [tabIndex]="tabIndex" mat-button type="button" (click)="increment()"
248
266
[disabled]="isDisabled" [color]="buttonColor" [disableRipple]="rippleDisabled">
249
267
Go
250
268
</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">
252
271
Link
253
272
</a>
254
273
<button mat-fab>Fab Button</button>
@@ -260,6 +279,7 @@ class TestApp {
260
279
isDisabled : boolean = false ;
261
280
rippleDisabled : boolean = false ;
262
281
buttonColor : ThemePalette ;
282
+ tabIndex : number ;
263
283
264
284
increment ( ) {
265
285
this . clickCount ++ ;
0 commit comments