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

Commit

Permalink
fix(tabs): don't select tabs on destroy
Browse files Browse the repository at this point in the history
Fixes #2155

Closes #2596
  • Loading branch information
Tom France authored and chrisirhc committed Oct 1, 2014
1 parent 192768e commit 9939867
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/tabs/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,19 @@ angular.module('ui.bootstrap.tabs', [])

ctrl.removeTab = function removeTab(tab) {
var index = tabs.indexOf(tab);
//Select a new tab if the tab to be removed is selected
if (tab.active && tabs.length > 1) {
//Select a new tab if the tab to be removed is selected and not destroyed
if (tab.active && tabs.length > 1 && !destroyed) {
//If this is the last tab, select the previous tab. else, the next tab.
var newActiveIndex = index == tabs.length - 1 ? index - 1 : index + 1;
ctrl.select(tabs[newActiveIndex]);
}
tabs.splice(index, 1);
};

var destroyed;
$scope.$on('$destroy', function() {
destroyed = true;
});
}])

/**
Expand Down

0 comments on commit 9939867

Please sign in to comment.