From 5f5435d1b8f22c1202fe6fec0b895887e5cc03c5 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 16 Sep 2014 13:08:36 -0600 Subject: [PATCH] fix(tabs): don't paginate on initial load when width is 0 Closes #271 --- src/components/tabs/js/pagination.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/tabs/js/pagination.js b/src/components/tabs/js/pagination.js index 588db82db7b..ac3ca794821 100644 --- a/src/components/tabs/js/pagination.js +++ b/src/components/tabs/js/pagination.js @@ -40,12 +40,17 @@ function linkTabPagination(scope, element, tabsCtrl, $q, $materialEffects ) { */ function updatePagination() { var dfd = $q.defer(); - var tabs = buttonBar.children(); var tabsWidth = element.prop('clientWidth') - PAGINATORS_WIDTH; + var needPagination = (tabsWidth > 0) && ((TAB_MIN_WIDTH * tabs.length) > tabsWidth); var paginationToggled = (needPagination !== pagination.active); + if (tabsWidth <= 0) { + //tabsWidth is 0 on initial load. Just instantly resolve the promise if it's 0 + return $q.when(); + } + pagination.active = needPagination; if (needPagination) {