fix(tooltip): close tooltips appended to body on location change

Closes #345
This commit is contained in:
Pawel Kozlowski
2013-05-04 07:18:11 -07:00
committed by Josh David Miller
parent 76fee1f9e1
commit 041261b536
2 changed files with 26 additions and 4 deletions
+20
View File
@@ -309,6 +309,26 @@ describe( '$tooltipProvider', function() {
expect( elmBody.children().length ).toBe( 1 );
expect( $body.children().length ).toEqual( bodyLength + 1 );
}));
it('should close on location change', inject( function( $rootScope, $compile) {
elmBody = angular.element(
'<div><span tooltip="tooltip text">Selector Text</span></div>'
);
scope = $rootScope;
$compile(elmBody)(scope);
scope.$digest();
elm = elmBody.find('span');
elmScope = elm.scope();
elm.trigger( 'mouseenter' );
expect( elmScope.tt_isOpen ).toBe( true );
scope.$broadcast('$locationChangeSuccess');
scope.$digest();
expect( elmScope.tt_isOpen ).toBe( false );
}));
});
describe( 'triggers', function() {
+6 -4
View File
@@ -266,6 +266,11 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position' ] )
element.bind( triggers.hide, hideTooltipBind );
}
});
//if a tooltip is attached to <body> we need to remove it on location change
if ( options.appendToBody ) {
scope.$on('$locationChangeSuccess', hide);
}
}
};
};
@@ -296,7 +301,4 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position' ] )
.directive( 'tooltipHtmlUnsafe', [ '$tooltip', function ( $tooltip ) {
return $tooltip( 'tooltipHtmlUnsafe', 'tooltip', 'mouseenter' );
}])
;
}]);