Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

(WIP) feat(tabs): make accessible #1714

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/tabs/test/tabs.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,28 @@ describe('tabs', function() {
titles().eq(1).find('a').click();
expect(scope.deselectFirst).toHaveBeenCalled();
});

it('should have aria markup for titles', function() {
var t = titles().find('a');

expect(t.eq(0).attr('tabindex')).toBe('0');
expect(t.eq(0).attr('aria-expanded')).toBe('true');
expect(t.eq(0).attr('aria-selected')).toBe('true');

expect(t.eq(1).attr('tabindex')).toBe('-1');
expect(t.eq(1).attr('aria-expanded')).toBe('false');
expect(t.eq(1).attr('aria-selected')).toBe('false');
});

it('should have aria markup for panes', function() {
var t = contents();

expect(t.eq(0).attr('tabindex')).toBe('0');
expect(t.eq(0).attr('aria-hidden')).toBe('false');

expect(t.eq(1).attr('tabindex')).toBe('-1');
expect(t.eq(1).attr('aria-hidden')).toBe('true');
});
});

describe('basics with initial active tab', function() {
Expand Down
4 changes: 2 additions & 2 deletions template/tabs/tab.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<li ng-class="{active: active, disabled: disabled}">
<a ng-click="select()" tab-heading-transclude>{{heading}}</a>
<li ng-class="{active: active, disabled: disabled}" role="presentation">
<a href ng-click="select()" role="tab" tabindex="{{active ? 0 : -1}}" aria-expanded="{{!!active}}" aria-selected="{{!!active}}" tab-heading-transclude>{{heading}}</a>
</li>
8 changes: 3 additions & 5 deletions template/tabs/tabset.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@

<div>
<ul class="nav nav-{{type || 'tabs'}}" ng-class="{'nav-stacked': vertical, 'nav-justified': justified}" ng-transclude></ul>
<ul class="nav nav-{{type || 'tabs'}}" ng-class="{'nav-stacked': vertical, 'nav-justified': justified}" role="tablist" ng-transclude></ul>
<div class="tab-content">
<div class="tab-pane"
ng-repeat="tab in tabs"
ng-class="{active: tab.active}"
<div class="tab-pane" ng-repeat="tab in tabs" ng-class="{active: tab.active}"
role="tabpanel" tabindex="{{tab.active ? 0 : -1}}" aria-hidden="{{!tab.active}}"
tab-content-transclude="tab">
</div>
</div>
Expand Down