This repository was archived by the owner on May 29, 2019. It is now read-only.
File tree 2 files changed +17
-2
lines changed
2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -28,11 +28,14 @@ angular.module('ui.bootstrap.tabs', [])
28
28
tabs . push ( tab ) ;
29
29
// we can't run the select function on the first tab
30
30
// since that would select it twice
31
- if ( tabs . length === 1 ) {
31
+ if ( tabs . length === 1 && tab . active !== false ) {
32
32
tab . active = true ;
33
33
} else if ( tab . active ) {
34
34
ctrl . select ( tab ) ;
35
35
}
36
+ else {
37
+ tab . active = false ;
38
+ }
36
39
} ;
37
40
38
41
ctrl . removeTab = function removeTab ( tab ) {
Original file line number Diff line number Diff line change @@ -384,8 +384,13 @@ describe('tabs', function() {
384
384
385
385
describe ( 'tabset controller' , function ( ) {
386
386
function mockTab ( isActive ) {
387
+ var _isActive ;
388
+ if ( isActive || isActive === false ) {
389
+ _isActive = isActive ;
390
+ }
391
+
387
392
return {
388
- active : ! ! isActive ,
393
+ active : _isActive ,
389
394
onSelect : angular . noop ,
390
395
onDeselect : angular . noop
391
396
} ;
@@ -459,6 +464,13 @@ describe('tabs', function() {
459
464
expect ( tab1 . active ) . toBe ( true ) ;
460
465
} ) ;
461
466
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
+
462
474
it ( 'should select a tab added that\'s already active' , function ( ) {
463
475
var tab1 = mockTab ( ) , tab2 = mockTab ( true ) ;
464
476
ctrl . addTab ( tab1 ) ;
You can’t perform that action at this time.
0 commit comments