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

Commit

Permalink
fix(tabs): adds a delayed call to update the ink bar after a tab is r…
Browse files Browse the repository at this point in the history
…emoved

Closes #573.
  • Loading branch information
robertmesserle committed Jan 12, 2015
1 parent 416079b commit 1a1095b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
6 changes: 6 additions & 0 deletions src/components/tabs/js/tabItemDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ function MdTabDirective($mdInkRipple, $compile, $mdUtil, $mdConstant, $timeout)
detachRippleFn();
tabsCtrl.remove(tabItemCtrl);
});
element.on('$destroy', function () {
//-- wait for item to be removed from the dom
$timeout(function () {
tabsCtrl.scope.$broadcast('$mdTabsChanged');
}, 0, false);
});

if (!angular.isDefined(attr.ngClick)) {
element.on('click', defaultClickListener);
Expand Down
18 changes: 7 additions & 11 deletions src/components/tabs/js/tabsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
angular.module('material.components.tabs')
.controller('$mdTabs', MdTabsController);

function MdTabsController($scope, $element, $mdUtil, $$rAF) {
function MdTabsController($scope, $element, $mdUtil, $timeout) {

var tabsList = $mdUtil.iterator([], false);
var self = this;
Expand Down Expand Up @@ -69,21 +69,17 @@ function MdTabsController($scope, $element, $mdUtil, $$rAF) {

function remove(tab, noReselect) {
if (!tabsList.contains(tab)) return;
if (noReselect) return;
var isSelectedItem = getSelectedItem() === tab,
newTab = previous() || next();

if (noReselect) {
// do nothing
} else if (getSelectedItem() === tab) {
if (tabsList.count() > 1) {
select(previous() || next());
} else {
deselect(tab);
}
}

deselect(tab);
tabsList.remove(tab);
tab.onRemove();

$scope.$broadcast('$mdTabsChanged');

if (isSelectedItem) { select(newTab); }
}

// Move a tab (used when ng-repeat order changes)
Expand Down

0 comments on commit 1a1095b

Please sign in to comment.