Skip to content

Commit

Permalink
fix(tooltip): show correct tooltip on ngRepeat
Browse files Browse the repository at this point in the history
Thanks to @red-0ne for the test case.

This commit reverts a1b1ec4
(angular-ui#2825) .

Fixes angular-ui#2935
  • Loading branch information
chrisirhc authored and Oron Nadiv committed Nov 18, 2014
1 parent b7ad1b8 commit f86999f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
38 changes: 38 additions & 0 deletions src/tooltip/test/tooltip.spec.js
Expand Up @@ -96,6 +96,44 @@ describe('tooltip', function() {
tt.trigger( 'mouseleave' );
}));

it('should show correct text when in an ngRepeat', inject( function( $compile, $timeout ) {

elm = $compile( angular.element(
'<ul>'+
'<li ng-repeat="item in items">'+
'<span tooltip="{{item.tooltip}}">{{item.name}}</span>'+
'</li>'+
'</ul>'
) )( scope );

scope.items = [
{ name: 'One', tooltip: 'First Tooltip' },
{ name: 'Second', tooltip: 'Second Tooltip' }
];

scope.$digest();

var tt_1 = angular.element( elm.find('li > span')[0] );
var tt_2 = angular.element( elm.find('li > span')[1] );

tt_1.trigger( 'mouseenter' );
tt_1.trigger( 'mouseleave' );

$timeout.flush();

tt_2.trigger( 'mouseenter' );

expect( tt_1.text() ).toBe( scope.items[0].name );
expect( tt_2.text() ).toBe( scope.items[1].name );

tooltipScope = tt_2.scope().$$childTail;
expect( tooltipScope.content ).toBe( scope.items[1].tooltip );
expect( elm.find( '.tooltip-inner' ).text() ).toBe( scope.items[1].tooltip );

tt_2.trigger( 'mouseleave' );

}));

it('should only have an isolate scope on the popup', inject( function ( $compile ) {
var ttScope;

Expand Down
3 changes: 2 additions & 1 deletion src/tooltip/tooltip.js
Expand Up @@ -236,7 +236,8 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
removeTooltip();
}
tooltipLinkedScope = ttScope.$new();
tooltip = tooltipLinker(tooltipLinkedScope);
tooltip = tooltipLinker(tooltipLinkedScope, angular.noop);
ttScope.$digest();
}

function removeTooltip() {
Expand Down

0 comments on commit f86999f

Please sign in to comment.