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

Commit 9939867

Browse files
Tom Francechrisirhc
Tom France
authored andcommitted
fix(tabs): don't select tabs on destroy
Fixes #2155 Closes #2596
1 parent 192768e commit 9939867

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/tabs/tabs.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,19 @@ angular.module('ui.bootstrap.tabs', [])
3737

3838
ctrl.removeTab = function removeTab(tab) {
3939
var index = tabs.indexOf(tab);
40-
//Select a new tab if the tab to be removed is selected
41-
if (tab.active && tabs.length > 1) {
40+
//Select a new tab if the tab to be removed is selected and not destroyed
41+
if (tab.active && tabs.length > 1 && !destroyed) {
4242
//If this is the last tab, select the previous tab. else, the next tab.
4343
var newActiveIndex = index == tabs.length - 1 ? index - 1 : index + 1;
4444
ctrl.select(tabs[newActiveIndex]);
4545
}
4646
tabs.splice(index, 1);
4747
};
48+
49+
var destroyed;
50+
$scope.$on('$destroy', function() {
51+
destroyed = true;
52+
});
4853
}])
4954

5055
/**

0 commit comments

Comments
 (0)