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

Commit 463d5e3

Browse files
Robert MesserleThomasBurleson
authored andcommitted
fix(tabs): fixes tab math to address issues when used within dialog
closes #7048 Closes #7118
1 parent dadece3 commit 463d5e3

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/components/tabs/js/tabsController.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -545,11 +545,13 @@ function MdTabsController ($scope, $element, $window, $mdConstant, $mdTabInkRipp
545545
function updatePagingWidth() {
546546
var width = 1;
547547
angular.forEach(getElements().dummies, function (element) {
548-
// uses `getBoundingClientRect().width` rather than `offsetWidth` to include decimal values
549-
// when calculating the total width
550-
width += Math.ceil(element.getBoundingClientRect().width);
548+
//-- Uses the larger value between `getBoundingClientRect().width` and `offsetWidth`. This
549+
// prevents `offsetWidth` value from being rounded down and causing wrapping issues, but
550+
// also handles scenarios where `getBoundingClientRect()` is inaccurate (ie. tabs inside
551+
// of a dialog)
552+
width += Math.max(element.offsetWidth, element.getBoundingClientRect().width);
551553
});
552-
angular.element(elements.paging).css('width', width + 'px');
554+
angular.element(elements.paging).css('width', Math.ceil(width) + 'px');
553555
}
554556

555557
function getMaxTabWidth () {

0 commit comments

Comments
 (0)