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

Commit

Permalink
fix(tooltip): prevent closing on $locationChangeSuccess
Browse files Browse the repository at this point in the history
- Remove incorrect logic for closing tooltip/popover on
  $locationChangeSuccess

Closes #5360
Fixes #5337
  • Loading branch information
Matthew McLeod authored and wesleycho committed Jan 28, 2016
1 parent 0b7e742 commit 48c9cd8
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 31 deletions.
19 changes: 0 additions & 19 deletions src/tooltip/test/tooltip.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -998,25 +998,6 @@ describe('$uibTooltipProvider', function() {
expect($body.children().length).toEqual(bodyLength);
}));

it('should close on location change', inject(function($rootScope, $compile) {
elmBody = angular.element(
'<div><span uib-tooltip="tooltip text">Selector Text</span></div>'
);

scope = $rootScope;
$compile(elmBody)(scope);
scope.$digest();
elm = elmBody.find('span');
elmScope = elm.scope();
tooltipScope = elmScope.$$childTail;

trigger(elm, 'mouseenter');
expect(tooltipScope.isOpen).toBe(true);

scope.$broadcast('$locationChangeSuccess');
scope.$digest();
expect(tooltipScope.isOpen).toBe(false);
}));
});

describe('triggers', function() {
Expand Down
13 changes: 1 addition & 12 deletions src/tooltip/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -540,18 +540,7 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.s
}

appendToBody = angular.isDefined(appendToBodyVal) ? appendToBodyVal : appendToBody;

// if a tooltip is attached to <body> we need to remove it on
// location change as its parent scope will probably not be destroyed
// by the change.
if (appendToBody) {
scope.$on('$locationChangeSuccess', function closeTooltipOnLocationChangeSuccess() {
if (ttScope.isOpen) {
hide();
}
});
}


// Make sure tooltip is destroyed and removed.
scope.$on('$destroy', function onDestroyTooltip() {
unregisterTriggers();
Expand Down

0 comments on commit 48c9cd8

Please sign in to comment.