Skip to content

Commit f2143b3

Browse files
committed
Prevent the opening of other tooltips if a non-closeable tooltip is open
1 parent c0a96a7 commit f2143b3

3 files changed

Lines changed: 25 additions & 7 deletions

File tree

dist/isotip.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,11 @@ module.exports = {
9191

9292
var trigger = evt.target || evt.srcElement
9393

94+
// If there's a tooltip open and it shouldn't close, don't close it _or_ open a new one
95+
if (self.currentTooltip && self.currentTooltip.getAttribute('data-autoclose') === 'false') {
96+
return
9497
// If there's already a tooltip open, close that one...
95-
if (self.currentTooltip && self.currentTooltip.getAttribute('data-autoclose') !== 'false') {
98+
} else if (self.currentTooltip) {
9699
// ...unless the user is clicking on the tooltip itself...
97100
if (trigger === self.currentTooltip) {
98101
return
@@ -133,8 +136,11 @@ module.exports = {
133136
return
134137
}
135138

139+
// If there's a tooltip open and it shouldn't close, don't close it _or_ open a new one
140+
if (self.currentTooltip && self.currentTooltip.getAttribute('data-autoclose') === 'false') {
141+
return
136142
// If there's already a tooltip open, close that one...
137-
if (self.currentTooltip && self.currentTooltip.getAttribute('data-autoclose') !== 'false') {
143+
} else if (self.currentTooltip) {
138144
// ...unless the user is hovering over the tooltip itself...
139145
if (trigger === self.currentTooltip) {
140146
return
@@ -194,8 +200,11 @@ module.exports = {
194200
return
195201
}
196202

203+
// If there's a tooltip open and it shouldn't close, don't close it _or_ open a new one
204+
if (self.currentTooltip && self.currentTooltip.getAttribute('data-autoclose') === 'false') {
205+
return
197206
// If there's already a tooltip open, close that one...
198-
if (self.currentTooltip && self.currentTooltip.getAttribute('data-autoclose') !== 'false') {
207+
} else if (self.currentTooltip) {
199208
self.close(self.currentTooltip)
200209
}
201210

0 commit comments

Comments
 (0)