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 opening when tooltipPopupDelay is present
Browse files Browse the repository at this point in the history
- Cancel the timeout when `tooltipPopupDelay` is present and the element with the tooltip directive becomes disabled

Closes #4098
Fixes #3611
  • Loading branch information
wesleycho committed Aug 4, 2015
1 parent 8359d73 commit 12c527a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/tooltip/test/tooltip.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ describe('tooltip', function() {
beforeEach(inject(function ($compile) {
scope.delay='1000';
elm = $compile(angular.element(
'<span tooltip="tooltip text" tooltip-popup-delay="{{delay}}">Selector Text</span>'
'<span tooltip="tooltip text" tooltip-popup-delay="{{delay}}" ng-disabled="disabled">Selector Text</span>'
))(scope);
elmScope = elm.scope();
tooltipScope = elmScope.$$childTail;
Expand Down Expand Up @@ -293,6 +293,19 @@ describe('tooltip', function() {
expect(tooltipScope.isOpen).toBe(true);
});

it('should not open if disabled is present', inject(function($timeout) {
elm.trigger('mouseenter');
expect(tooltipScope.isOpen).toBe(false);

$timeout.flush(500);
expect(tooltipScope.isOpen).toBe(false);
elmScope.disabled = true;
elmScope.$digest();

$timeout.flush();
expect(tooltipScope.isOpen).toBe(false);
}));

});

describe( 'with a trigger attribute', function() {
Expand Down
4 changes: 4 additions & 0 deletions src/tooltip/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
}

attrs.$observe( 'disabled', function ( val ) {
if (popupTimeout && val) {
$timeout.cancel(popupTimeout);
}

if (val && ttScope.isOpen ) {
hide();
}
Expand Down

0 comments on commit 12c527a

Please sign in to comment.