From 666a3ae53dcb369c2797e89d300f4ec9843e4f81 Mon Sep 17 00:00:00 2001 From: Vadim Kazakov Date: Thu, 19 Sep 2024 10:22:15 -0600 Subject: [PATCH] fix Tooltip component complete handlers [#37474] * ensure `complete` handlers for `show` and `hide` check if the commponent was disposed * what can happen is the element can get removed from the DOM and the tooltip would get disposed * when the complete handler would run at a later point the component would be disposed and would throw various null related exceptions --- js/src/tooltip.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 097477f7a1a8..32be0a297351 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -227,6 +227,11 @@ class Tooltip extends BaseComponent { } const complete = () => { + // component disposed + if (!this._element) { + return + } + EventHandler.trigger(this._element, this.constructor.eventName(EVENT_SHOWN)) if (this._isHovered === false) { @@ -266,6 +271,11 @@ class Tooltip extends BaseComponent { this._isHovered = null // it is a trick to support manual triggering const complete = () => { + // component disposed + if (!this._element) { + return + } + if (this._isWithActiveTrigger()) { return }