diff --git a/src/components/tabs/js/tabsController.js b/src/components/tabs/js/tabsController.js index b246f3f69fd..5f1d9a99851 100644 --- a/src/components/tabs/js/tabsController.js +++ b/src/components/tabs/js/tabsController.js @@ -545,11 +545,13 @@ function MdTabsController ($scope, $element, $window, $mdConstant, $mdTabInkRipp function updatePagingWidth() { var width = 1; angular.forEach(getElements().dummies, function (element) { - // uses `getBoundingClientRect().width` rather than `offsetWidth` to include decimal values - // when calculating the total width - width += Math.ceil(element.getBoundingClientRect().width); + //-- Uses the larger value between `getBoundingClientRect().width` and `offsetWidth`. This + // prevents `offsetWidth` value from being rounded down and causing wrapping issues, but + // also handles scenarios where `getBoundingClientRect()` is inaccurate (ie. tabs inside + // of a dialog) + width += Math.max(element.offsetWidth, element.getBoundingClientRect().width); }); - angular.element(elements.paging).css('width', width + 'px'); + angular.element(elements.paging).css('width', Math.ceil(width) + 'px'); } function getMaxTabWidth () {