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

Commit

Permalink
fix(tooltip): guard against missing offsetParent.
Browse files Browse the repository at this point in the history
  • Loading branch information
jelbourn committed Dec 7, 2015
1 parent 992d9b5 commit d0b7bac
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/components/tooltip/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,13 @@ function MdTooltipDirective($timeout, $window, $$rAF, $document, $mdUtil, $mdThe
var tipRect = $mdUtil.offsetRect(element, tooltipParent);
var parentRect = $mdUtil.offsetRect(parent, tooltipParent);
var newPosition = getPosition(scope.direction);
var offsetParent = element.prop('offsetParent');

// If the user provided a direction, just nudge the tooltip onto the screen
// Otherwise, recalculate based on 'top' since default is 'bottom'
if (scope.direction) {
newPosition = fitInParent(newPosition);
} else if (newPosition.top > element.prop('offsetParent').scrollHeight - tipRect.height - TOOLTIP_WINDOW_EDGE_SPACE) {
} else if (offsetParent && newPosition.top > offsetParent.scrollHeight - tipRect.height - TOOLTIP_WINDOW_EDGE_SPACE) {
newPosition = fitInParent(getPosition('top'));
}

Expand Down

0 comments on commit d0b7bac

Please sign in to comment.