Skip to content

Commit 4d77f39

Browse files
Tom FranceOron Nadiv
Tom France
authored and
Oron Nadiv
committed
fix(tabs): don't select tabs on destroy
Fixes angular-ui#2155 Closes angular-ui#2596
1 parent 801a6c0 commit 4d77f39

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Diff for: src/tabs/tabs.js

+7-2
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)