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

feat(tooltip): Prevent close tooltip with 'esc' key #6626

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
7 changes: 4 additions & 3 deletions src/stackedMap/stackedMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ angular.module('ui.bootstrap.stackedMap', [])
var stack = [];

return {
add: function(key, value) {
add: function(key, value, options) {
stack.push({
key: key,
value: value
value: value,
options: options
});
},
get: function(key) {
Expand Down Expand Up @@ -51,4 +52,4 @@ angular.module('ui.bootstrap.stackedMap', [])
};
}
};
});
});
14 changes: 8 additions & 6 deletions src/tooltip/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.s
function keypressListener(e) {
if (e.which === 27) {
var last = openedTooltips.top();
if (last) {
var enableEsc = last ? last.options.enableEsc : true;
if (last && enableEsc) {
last.value.close();
last = null;
}
Expand Down Expand Up @@ -146,6 +147,7 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.s
var positionTimeout;
var adjustmentTimeout;
var appendToBody = angular.isDefined(options.appendToBody) ? options.appendToBody : false;
var enableEsc = !angular.isDefined(attrs[prefix + 'EnableEsc']);
var triggers = getTriggers(undefined);
var hasEnableExp = angular.isDefined(attrs[prefix + 'Enable']);
var ttScope = scope.$new(true);
Expand Down Expand Up @@ -334,9 +336,9 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.s
}
});

openedTooltips.add(ttScope, {
close: hide
});
openedTooltips.add(ttScope,
{ close: hide },
{ enableEsc: enableEsc });

prepObservers();
}
Expand All @@ -348,15 +350,15 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.s

if (tooltip) {
tooltip.remove();

tooltip = null;
if (adjustmentTimeout) {
$timeout.cancel(adjustmentTimeout);
}
}

openedTooltips.remove(ttScope);

if (tooltipLinkedScope) {
tooltipLinkedScope.$destroy();
tooltipLinkedScope = null;
Expand Down