Skip to content

Commit

Permalink
fix(tabs): prevent focus of disabled tabs
Browse files Browse the repository at this point in the history
Fixes #1430
  • Loading branch information
troy authored and pkozlowski-opensource committed Apr 5, 2017
1 parent 4cbea99 commit 7d1dd97
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/tabset/tabset.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,12 @@ function expectTabs(nativeEl: HTMLElement, active: boolean[], disabled?: boolean

if (disabled[i]) {
expect(tabTitles[i]).toHaveCssClass('disabled');
expect(tabTitles[i].getAttribute('aria-disabled')).toBe('true');
expect(tabTitles[i].getAttribute('tabindex')).toBe('-1');
} else {
expect(tabTitles[i]).not.toHaveCssClass('disabled');
expect(tabTitles[i].getAttribute('aria-disabled')).toBe('false');
expect(tabTitles[i].getAttribute('tabindex')).toBeNull();
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/tabset/tabset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ export interface NgbTabChangeEvent {
<ul [class]="'nav nav-' + type + ' justify-content-' + justify" role="tablist">
<li class="nav-item" *ngFor="let tab of tabs">
<a [id]="tab.id" class="nav-link" [class.active]="tab.id === activeId" [class.disabled]="tab.disabled"
href (click)="!!select(tab.id)" role="tab" [attr.aria-controls]="tab.id + '-panel'" [attr.aria-expanded]="tab.id === activeId">
href (click)="!!select(tab.id)" role="tab" [attr.tabindex]="(tab.disabled ? '-1': undefined)"
[attr.aria-controls]="tab.id + '-panel'" [attr.aria-expanded]="tab.id === activeId" [attr.aria-disabled]="tab.disabled">
{{tab.title}}<template [ngTemplateOutlet]="tab.titleTpl?.templateRef"></template>
</a>
</li>
Expand Down

0 comments on commit 7d1dd97

Please sign in to comment.