Skip to content

Commit bf57c13

Browse files
author
Guillaume Chau
committed
Fix cases of tooltips not being disposed on Firefox
1 parent 6a73a4c commit bf57c13

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/tooltip.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ export default class Tooltip {
7272
// set initial state
7373
this._isOpen = false
7474

75+
this._isDisposed = false
76+
7577
// set event listeners
7678
this._setEventListeners(reference, events, options)
7779
}
@@ -349,13 +351,19 @@ export default class Tooltip {
349351

350352
// Fix position
351353
requestAnimationFrame(() => {
352-
if (this.popperInstance) {
354+
if (!this._isDisposed && this.popperInstance) {
353355
this.popperInstance.update()
354356

355357
// Show the tooltip
356358
requestAnimationFrame(() => {
357-
tooltipNode.setAttribute('aria-hidden', 'false')
359+
if (!this._isDisposed) {
360+
tooltipNode.setAttribute('aria-hidden', 'false')
361+
} else {
362+
this.dispose()
363+
}
358364
})
365+
} else {
366+
this.dispose()
359367
}
360368
})
361369

@@ -392,6 +400,8 @@ export default class Tooltip {
392400
}
393401

394402
_dispose () {
403+
this._isDisposed = true
404+
395405
// remove event listeners first to prevent any unexpected behaviour
396406
this._events.forEach(({ func, event }) => {
397407
this.reference.removeEventListener(event, func)

0 commit comments

Comments
 (0)