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

Commit

Permalink
fix(tooltip): cancel timeout when hidden
Browse files Browse the repository at this point in the history
- Cancel timeout when hidden so that positioning does not incorrectly occur when not visible

Closes #6226
Fixes #6221
  • Loading branch information
Johnnyrook777 authored and wesleycho committed Oct 10, 2016
1 parent 14384fc commit 7855976
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/tooltip/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.s
var showTimeout;
var hideTimeout;
var positionTimeout;
var adjustmentTimeout;
var appendToBody = angular.isDefined(options.appendToBody) ? options.appendToBody : false;
var triggers = getTriggers(undefined);
var hasEnableExp = angular.isDefined(attrs[prefix + 'Enable']);
Expand Down Expand Up @@ -176,12 +177,13 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.s
tooltip.addClass(options.placementClassPrefix + ttPosition.placement);
}

$timeout(function() {
adjustmentTimeout = $timeout(function() {
var currentHeight = angular.isDefined(tooltip.offsetHeight) ? tooltip.offsetHeight : tooltip.prop('offsetHeight');
var adjustment = $position.adjustTop(placementClasses, elementPos, initialHeight, currentHeight);
if (adjustment) {
tooltip.css(adjustment);
}
adjustmentTimeout = null;
}, 0, false);

// first time through tt element will have the
Expand Down Expand Up @@ -346,7 +348,11 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.s

if (tooltip) {
tooltip.remove();

tooltip = null;
if (adjustmentTimeout) {
$timeout.cancel(adjustmentTimeout);
}
}

openedTooltips.remove(ttScope);
Expand Down

0 comments on commit 7855976

Please sign in to comment.