Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
fix(tabs): prevents select/deselect events from firing on destroy
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Messerle committed Jun 6, 2015
1 parent b2c568c commit 1ba0686
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/components/tabs/js/tabsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ angular
*/
function MdTabsController ($scope, $element, $window, $timeout, $mdConstant, $mdTabInkRipple,
$mdUtil, $animate) {
var ctrl = this,
locked = false,
elements = getElements(),
queue = [];
var ctrl = this,
locked = false,
elements = getElements(),
queue = [],
destroyed = false;

ctrl.scope = $scope;
ctrl.parent = $scope.$parent;
Expand Down Expand Up @@ -56,6 +57,7 @@ function MdTabsController ($scope, $element, $window, $timeout, $mdConstant, $md
}

function cleanup () {
destroyed = true;
angular.element($window).off('resize', handleWindowResize);
angular.element(elements.paging).off('DOMSubtreeModified', ctrl.updateInkBarStyles);
}
Expand Down Expand Up @@ -179,7 +181,7 @@ function MdTabsController ($scope, $element, $window, $timeout, $mdConstant, $md
refreshIndex();
//-- when removing a tab, if the selected index did not change, we have to manually trigger the
// tab select/deselect events
if ($scope.selectedIndex === selectedIndex) {
if ($scope.selectedIndex === selectedIndex && !destroyed) {
tab.scope.deselect();
ctrl.tabs[$scope.selectedIndex] && ctrl.tabs[$scope.selectedIndex].scope.select();
}
Expand Down

0 comments on commit 1ba0686

Please sign in to comment.