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

fix(tooltip): prevent opening when tooltipPopupDelay is present #4098

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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