Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bind popper disposal with tooltip removal, trying to fix tooltip/popper inconsistencies #37235

Merged
merged 1 commit into from Oct 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 8 additions & 16 deletions js/src/tooltip.js
Expand Up @@ -172,10 +172,6 @@ class Tooltip extends BaseComponent {

EventHandler.off(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler)

if (this.tip) {
this.tip.remove()
}

if (this._element.getAttribute('data-bs-original-title')) {
this._element.setAttribute('title', this._element.getAttribute('data-bs-original-title'))
}
Expand All @@ -202,10 +198,7 @@ class Tooltip extends BaseComponent {
}

// todo v6 remove this OR make it optional
if (this.tip) {
this.tip.remove()
this.tip = null
}
this._disposePopper()

const tip = this._getTipElement()

Expand All @@ -218,11 +211,7 @@ class Tooltip extends BaseComponent {
EventHandler.trigger(this._element, this.constructor.eventName(EVENT_INSERTED))
}

if (this._popper) {
this._popper.update()
} else {
this._popper = this._createPopper(tip)
}
this._popper = this._createPopper(tip)

tip.classList.add(CLASS_NAME_SHOW)

Expand Down Expand Up @@ -281,13 +270,11 @@ class Tooltip extends BaseComponent {
}

if (!this._isHovered) {
tip.remove()
this._disposePopper()
}

this._element.removeAttribute('aria-describedby')
EventHandler.trigger(this._element, this.constructor.eventName(EVENT_HIDDEN))

this._disposePopper()
}

this._queueCallback(complete, this.tip, this._isAnimated())
Expand Down Expand Up @@ -612,6 +599,11 @@ class Tooltip extends BaseComponent {
this._popper.destroy()
this._popper = null
}

if (this.tip) {
this.tip.remove()
this.tip = null
}
}

// Static
Expand Down