Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Commit f975d44

Browse files
authored
feat(fab): Add tabIndex property (#216)
1 parent 235d73a commit f975d44

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

src/demo-app/components/fab-demo/fab-demo.component.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ <h1 mdc-typography-display1>Floating Action Button</h1>
2828
<tbody>
2929
<tr>
3030
<td>mini: boolean</td>
31-
<td>Makes the fab smaller (40 x 40 pixels).</td>
31+
<td>Make the fab smaller (40 x 40 pixels).</td>
32+
</tr>
33+
<tr>
34+
<td>tabIndex: number</td>
35+
<td>Set the tabindex of the button. (Default: 0).</td>
3236
</tr>
3337
<tr>
3438
<td>disableRipple: boolean</td>

src/demo-app/components/fab-demo/fab-demo.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ import { Component } from '@angular/core';
55
templateUrl: './fab-demo.component.html'
66
})
77
export class FabDemoComponent {
8-
isMini: boolean;
9-
isRippleDisabled: boolean;
8+
isMini: boolean = false;
9+
isRippleDisabled: boolean = false;
1010
}

src/lib/fab/fab.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export class MdcFabIconDirective {
3030
})
3131
export class MdcFabComponent {
3232
@Input() mini: boolean;
33+
@Input('attr.tabindex') tabIndex: number = 0;
3334
@Input()
3435
get disableRipple() { return this._ripple.disabled; }
3536
set disableRipple(value) {

test/unit/fab/fab.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ describe('MdcFabComponent', () => {
5555
buttonDebugElement.nativeElement.click();
5656
expect(testComponent.clickCount).toBe(1);
5757
});
58+
59+
it('#should preserve any given tabIndex', () => {
60+
expect(buttonDebugElement.nativeElement.tabIndex).toBe(2);
61+
});
5862
});
5963
});
6064

@@ -63,6 +67,7 @@ describe('MdcFabComponent', () => {
6367
template: `
6468
<button mdc-fab
6569
(click)="increment()"
70+
[tabIndex]="customTabIndex"
6671
[disableRipple]="isRippleDisabled"
6772
[mini]="isMini">
6873
<mdc-fab-icon>search</mdc-fab-icon>
@@ -73,6 +78,7 @@ class SimpleButton {
7378
isMini: boolean = false;
7479
isRippleDisabled: boolean = false;
7580
clickCount: number = 0;
81+
customTabIndex: number = 2;
7682

7783
increment() {
7884
this.clickCount++;

0 commit comments

Comments
 (0)