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

Commit 12c527a

Browse files
committed
fix(tooltip): prevent opening when tooltipPopupDelay is present
- Cancel the timeout when `tooltipPopupDelay` is present and the element with the tooltip directive becomes disabled Closes #4098 Fixes #3611
1 parent 8359d73 commit 12c527a

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/tooltip/test/tooltip.spec.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ describe('tooltip', function() {
260260
beforeEach(inject(function ($compile) {
261261
scope.delay='1000';
262262
elm = $compile(angular.element(
263-
'<span tooltip="tooltip text" tooltip-popup-delay="{{delay}}">Selector Text</span>'
263+
'<span tooltip="tooltip text" tooltip-popup-delay="{{delay}}" ng-disabled="disabled">Selector Text</span>'
264264
))(scope);
265265
elmScope = elm.scope();
266266
tooltipScope = elmScope.$$childTail;
@@ -293,6 +293,19 @@ describe('tooltip', function() {
293293
expect(tooltipScope.isOpen).toBe(true);
294294
});
295295

296+
it('should not open if disabled is present', inject(function($timeout) {
297+
elm.trigger('mouseenter');
298+
expect(tooltipScope.isOpen).toBe(false);
299+
300+
$timeout.flush(500);
301+
expect(tooltipScope.isOpen).toBe(false);
302+
elmScope.disabled = true;
303+
elmScope.$digest();
304+
305+
$timeout.flush();
306+
expect(tooltipScope.isOpen).toBe(false);
307+
}));
308+
296309
});
297310

298311
describe( 'with a trigger attribute', function() {

src/tooltip/tooltip.js

+4
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,10 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
299299
}
300300

301301
attrs.$observe( 'disabled', function ( val ) {
302+
if (popupTimeout && val) {
303+
$timeout.cancel(popupTimeout);
304+
}
305+
302306
if (val && ttScope.isOpen ) {
303307
hide();
304308
}

0 commit comments

Comments
 (0)