From 5726e3efae782dc400c39182943b6b33de57bb12 Mon Sep 17 00:00:00 2001 From: Chris Chua Date: Tue, 18 Nov 2014 23:30:43 -0800 Subject: [PATCH] fix(tooltip): incorrect position when text wraps The $digest that was removed in 32c470 is actually necessary to get the tooltip contents rendered. The rendered content is important when the tooltip is on the right edge. See Plunker in #2995: http://plnkr.co/edit/8GZ5F5zj3Xe6IinXQz74?p=preview Reverts change in 32c470 (#2995) but fixes it in another way. Fixes #2995 Fixes #2992 Fixes #2951 Closes #2996 --- src/tooltip/tooltip.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/tooltip/tooltip.js b/src/tooltip/tooltip.js index 36351bc145..4659e8bdc7 100644 --- a/src/tooltip/tooltip.js +++ b/src/tooltip/tooltip.js @@ -189,14 +189,7 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap // Set the initial positioning. tooltip.css({ top: 0, left: 0, display: 'block' }); - - // Now we add it to the DOM because need some info about it. But it's not - // visible yet anyway. - if ( appendToBody ) { - $document.find( 'body' ).append( tooltip ); - } else { - element.after( tooltip ); - } + ttScope.$digest(); positionTooltip(); @@ -236,7 +229,13 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap removeTooltip(); } tooltipLinkedScope = ttScope.$new(); - tooltip = tooltipLinker(tooltipLinkedScope, angular.noop); + tooltip = tooltipLinker(tooltipLinkedScope, function (tooltip) { + if ( appendToBody ) { + $document.find( 'body' ).append( tooltip ); + } else { + element.after( tooltip ); + } + }); } function removeTooltip() {