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

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
(#2825) .

Fixes #2935
  • Loading branch information
chrisirhc committed Nov 11, 2014
1 parent 35d0cc1 commit b4832c4
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 b4832c4

Please sign in to comment.