diff --git a/src/tooltip/test/tooltip.spec.js b/src/tooltip/test/tooltip.spec.js index c10b147d96..578b95ac6b 100644 --- a/src/tooltip/test/tooltip.spec.js +++ b/src/tooltip/test/tooltip.spec.js @@ -260,7 +260,7 @@ describe('tooltip', function() { beforeEach(inject(function ($compile) { scope.delay='1000'; elm = $compile(angular.element( - 'Selector Text' + 'Selector Text' ))(scope); elmScope = elm.scope(); tooltipScope = elmScope.$$childTail; @@ -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() { diff --git a/src/tooltip/tooltip.js b/src/tooltip/tooltip.js index dde89c4b46..2f1a571e54 100644 --- a/src/tooltip/tooltip.js +++ b/src/tooltip/tooltip.js @@ -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(); }