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 error when navigating away from tabs section whil…
Browse files Browse the repository at this point in the history
…e using Angular 1.4.x
  • Loading branch information
Robert Messerle committed Jul 17, 2015
1 parent 7bbfd1f commit 31bb121
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/components/tabs/js/tabsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,12 +348,13 @@ function MdTabsController ($scope, $element, $window, $mdConstant, $mdTabInkRipp
* @param tabData
*/
function removeTab (tabData) {
if (destroyed) return;
var selectedIndex = ctrl.selectedIndex,
tab = ctrl.tabs.splice(tabData.getIndex(), 1)[ 0 ];
refreshIndex();
// when removing a tab, if the selected index did not change, we have to manually trigger the
// tab select/deselect events
if (ctrl.selectedIndex === selectedIndex && !destroyed) {
if (ctrl.selectedIndex === selectedIndex) {
tab.scope.deselect();
ctrl.tabs[ ctrl.selectedIndex ] && ctrl.tabs[ ctrl.selectedIndex ].scope.select();
}
Expand Down

0 comments on commit 31bb121

Please sign in to comment.