Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit 457f10c

Browse files
dabos-GFIwesleycho
authored andcommitted
fix(tooltip): correctly position tooltip
- Use a style reset so the DOM recalculates values before correctly positioning the tooltip Closes #4311 Fixes #4195
1 parent b1e98b1 commit 457f10c

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/tooltip/tooltip.js

+14-7
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,20 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.b
132132

133133
var positionTooltip = function() {
134134
if (!tooltip) { return; }
135-
136-
var ttPosition = $position.positionElements(element, tooltip, ttScope.placement, appendToBody);
137-
ttPosition.top += 'px';
138-
ttPosition.left += 'px';
139-
140-
// Now set the calculated positioning.
141-
tooltip.css(ttPosition);
135+
136+
// Reset the positioning and box size for correct width and height values.
137+
tooltip.css({ top: 0, left: 0, width: 'auto', height: 'auto' });
138+
139+
var ttBox = $position.position(tooltip);
140+
var ttCss = $position.positionElements(element, tooltip, ttScope.placement, appendToBody);
141+
ttCss.top += 'px';
142+
ttCss.left += 'px';
143+
144+
ttCss.width = ttBox.width + 'px';
145+
ttCss.height = ttBox.height + 'px';
146+
147+
// Now set the calculated positioning and size.
148+
tooltip.css(ttCss);
142149
};
143150

144151
var positionTooltipAsync = function() {

0 commit comments

Comments
 (0)