Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
fix #2290 Added an accessibility feature for tab directive
  • Loading branch information
justin-john committed Jun 7, 2014
commit f502b8b362cdefff55e92478bea6a70241bc010a
30 changes: 30 additions & 0 deletions src/tabs/test/tabs.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -778,4 +778,34 @@ describe('tabs', function() {
expect(elm.find('.outer-tab-content').eq(0).text().trim()).toEqual(scope.tabs[0].content);
}));
});
describe('tab switching using keyboard', function() {
beforeEach(inject(function($compile, $rootScope) {
scope = $rootScope.$new();

elm = $compile([
'<tabset>',
' <tab><tab-heading>heading 0</tab-heading>content 0</tab>',
' <tab><tab-heading>heading 1</tab-heading>content 1</tab>',
' <tab><tab-heading>heading 2</tab-heading>content 2</tab>',
'</tabset>'
].join('\n'))(scope);
scope.$apply();
}));

it('should switch tab on focus', function() {
titles().eq(0).find('a').click();

titles().eq(1).find('a').focus();
expect(titles().eq(1)).toHaveClass('active');
expect(contents().eq(1)).toHaveClass('active');
expect(titles().eq(0)).not.toHaveClass('active');
expect(contents().eq(0)).not.toHaveClass('active');

titles().eq(2).find('a').focus();
expect(titles().eq(2)).toHaveClass('active');
expect(contents().eq(2)).toHaveClass('active');
expect(titles().eq(1)).not.toHaveClass('active');
expect(contents().eq(1)).not.toHaveClass('active');
});
});
});
2 changes: 1 addition & 1 deletion 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>
<a href ng-focus="select()" ng-click="select()" tab-heading-transclude>{{heading}}</a>
</li>