diff --git a/src/components/tabs/js/paginationDirective.js b/src/components/tabs/js/paginationDirective.js index d51353d975f..a363acc0f2b 100644 --- a/src/components/tabs/js/paginationDirective.js +++ b/src/components/tabs/js/paginationDirective.js @@ -20,11 +20,12 @@ function TabPaginationDirective($mdConstant, $window, $$rAF, $$q, $timeout, $mdM var tabs = element[0].getElementsByTagName('md-tab'); var debouncedUpdatePagination = $$rAF.debounce(updatePagination); var tabsParent = element.children(); + var locked = false; var state = scope.pagination = { page: -1, active: false, - clickNext: function() { userChangePage(+1); }, - clickPrevious: function() { userChangePage(-1); } + clickNext: function() { locked || userChangePage(+1); }, + clickPrevious: function() { locked || userChangePage(-1); } }; scope.$on('$mdTabsChanged', debouncedUpdatePagination); @@ -47,7 +48,10 @@ function TabPaginationDirective($mdConstant, $window, $$rAF, $$q, $timeout, $mdM } else { // Go to the new page, wait for the page transition to end, then focus. oldTab && oldTab.element.blur(); - setPage(pageIndex).then(function() { tab.element.focus(); }); + setPage(pageIndex).then(function() { + locked = false; + tab.element.focus(); + }); } } @@ -57,6 +61,7 @@ function TabPaginationDirective($mdConstant, $window, $$rAF, $$q, $timeout, $mdM var newPage = Math.max(0, Math.min(sizeData.pages.length - 1, state.page + increment)); var newTabIndex = sizeData.pages[newPage][ increment > 0 ? 'firstTabIndex' : 'lastTabIndex' ]; var newTab = tabsCtrl.itemAt(newTabIndex); + locked = true; onTabFocus(newTab); }