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

Commit 895a228

Browse files
RobJacobswesleycho
authored andcommitted
fix(tooltip): tooltip w/ template position
When using a template with the tooltip/popover the position funciton needs to be called at the end of the $digest cycle to ensure correct positioning in case the template content size has changed Closes: #4144 Fixes: #4090
1 parent b21c9ab commit 895a228

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

Diff for: src/tooltip/tooltip.js

+16-4
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
126126
var triggers = getTriggers( undefined );
127127
var hasEnableExp = angular.isDefined(attrs[prefix+'Enable']);
128128
var ttScope = scope.$new(true);
129+
var repositionScheduled = false;
129130

130131
var positionTooltip = function () {
131132
if (!tooltip) { return; }
@@ -254,11 +255,21 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
254255

255256
if (options.useContentExp) {
256257
tooltipLinkedScope.$watch('contentExp()', function (val) {
257-
positionTooltipAsync();
258-
if (!val && ttScope.isOpen ) {
258+
if (!val && ttScope.isOpen) {
259259
hide();
260260
}
261261
});
262+
263+
tooltipLinkedScope.$watch(function() {
264+
if (!repositionScheduled) {
265+
repositionScheduled = true;
266+
tooltipLinkedScope.$$postDigest(function() {
267+
repositionScheduled = false;
268+
positionTooltipAsync();
269+
});
270+
}
271+
});
272+
262273
}
263274
}
264275

@@ -290,10 +301,11 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
290301
if (!options.useContentExp) {
291302
attrs.$observe( type, function ( val ) {
292303
ttScope.content = val;
293-
positionTooltipAsync();
294304

295-
if (!val && ttScope.isOpen ) {
305+
if (!val && ttScope.isOpen) {
296306
hide();
307+
} else {
308+
positionTooltipAsync();
297309
}
298310
});
299311
}

0 commit comments

Comments
 (0)