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

Commit 91b5fb6

Browse files
karol-fwesleycho
authored andcommitted
feat(tabs): it should not select first not active tab as selected
1 parent a5a82d9 commit 91b5fb6

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/tabs/tabs.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,14 @@ angular.module('ui.bootstrap.tabs', [])
2828
tabs.push(tab);
2929
// we can't run the select function on the first tab
3030
// since that would select it twice
31-
if (tabs.length === 1) {
31+
if (tabs.length === 1 && tab.active !== false) {
3232
tab.active = true;
3333
} else if (tab.active) {
3434
ctrl.select(tab);
3535
}
36+
else {
37+
tab.active = false;
38+
}
3639
};
3740

3841
ctrl.removeTab = function removeTab(tab) {

src/tabs/test/tabs.spec.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,13 @@ describe('tabs', function() {
384384

385385
describe('tabset controller', function() {
386386
function mockTab(isActive) {
387+
var _isActive;
388+
if (isActive || isActive === false) {
389+
_isActive = isActive;
390+
}
391+
387392
return {
388-
active: !!isActive,
393+
active: _isActive,
389394
onSelect : angular.noop,
390395
onDeselect : angular.noop
391396
};
@@ -459,6 +464,13 @@ describe('tabs', function() {
459464
expect(tab1.active).toBe(true);
460465
});
461466

467+
it('should not select first active === false tab as selected', function() {
468+
var tab = mockTab(false);
469+
470+
ctrl.addTab(tab);
471+
expect(tab.active).toBe(false);
472+
});
473+
462474
it('should select a tab added that\'s already active', function() {
463475
var tab1 = mockTab(), tab2 = mockTab(true);
464476
ctrl.addTab(tab1);

0 commit comments

Comments
 (0)