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

Commit

Permalink
fix(tooltip): tooltip w/ template position
Browse files Browse the repository at this point in the history
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
  • Loading branch information
RobJacobs authored and wesleycho committed Aug 7, 2015
1 parent b21c9ab commit 895a228
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/tooltip/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
var triggers = getTriggers( undefined );
var hasEnableExp = angular.isDefined(attrs[prefix+'Enable']);
var ttScope = scope.$new(true);
var repositionScheduled = false;

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

if (options.useContentExp) {
tooltipLinkedScope.$watch('contentExp()', function (val) {
positionTooltipAsync();
if (!val && ttScope.isOpen ) {
if (!val && ttScope.isOpen) {
hide();
}
});

tooltipLinkedScope.$watch(function() {
if (!repositionScheduled) {
repositionScheduled = true;
tooltipLinkedScope.$$postDigest(function() {
repositionScheduled = false;
positionTooltipAsync();
});
}
});

}
}

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

if (!val && ttScope.isOpen ) {
if (!val && ttScope.isOpen) {
hide();
} else {
positionTooltipAsync();
}
});
}
Expand Down

0 comments on commit 895a228

Please sign in to comment.