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

Commit 58e8ef4

Browse files
fix(tooltip): triggers should be local to tooltip instances
Closes #692
1 parent f45815c commit 58e8ef4

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

src/tooltip/test/tooltip.spec.js

+26
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,32 @@ describe('tooltip', function() {
209209
elm.trigger('fakeTriggerAttr');
210210
expect( elmScope.tt_isOpen ).toBeFalsy();
211211
}));
212+
213+
it('should not share triggers among different element instances - issue 692', inject( function ($compile) {
214+
215+
scope.test = true;
216+
elmBody = angular.element(
217+
'<div>' +
218+
'<input tooltip="Hello!" tooltip-trigger="{{ (test && \'mouseenter\' || \'click\') }}" />' +
219+
'<input tooltip="Hello!" tooltip-trigger="{{ (test && \'mouseenter\' || \'click\') }}" />' +
220+
'</div>'
221+
);
222+
223+
$compile(elmBody)(scope);
224+
scope.$apply();
225+
var elm1 = elmBody.find('input').eq(0);
226+
var elm2 = elmBody.find('input').eq(1);
227+
var elmScope1 = elm1.scope();
228+
var elmScope2 = elm2.scope();
229+
230+
scope.$apply('test = false');
231+
232+
elm2.trigger('mouseenter');
233+
expect( elmScope2.tt_isOpen ).toBeFalsy();
234+
235+
elm2.click();
236+
expect( elmScope2.tt_isOpen ).toBeTruthy();
237+
}));
212238
});
213239

214240
describe( 'with an append-to-body attribute', function() {

src/tooltip/tooltip.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position' ] )
9999
}
100100

101101
var directiveName = snake_case( type );
102-
var triggers = setTriggers( undefined );
103102

104103
var startSym = $interpolate.startSymbol();
105104
var endSym = $interpolate.endSymbol();
@@ -122,6 +121,7 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position' ] )
122121
var popupTimeout;
123122
var $body;
124123
var appendToBody = angular.isDefined( options.appendToBody ) ? options.appendToBody : false;
124+
var triggers = setTriggers( undefined );
125125

126126
// By default, the tooltip is not open.
127127
// TODO add ability to start tooltip opened

0 commit comments

Comments
 (0)