Make sure all consumers of the tooltip mixin clean up when unmounted.

This commit is contained in:
pk
2026-08-26 15:33:14 +02:00
parent 7f6b03d602
commit 9a0660767c
3 changed files with 8 additions and 6 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@tp/tp-tooltip",
"version": "1.0.0",
"version": "1.1.0",
"description": "",
"main": "tp-tooltip.js",
"scripts": {
+7
View File
@@ -8,6 +8,8 @@ import './tp-tooltip.js';
/**
* Elements implementing this mixin are able to show tooltip on mouse over.
* The tooltip is automatically hidden and removed when the element is
* disconnected from the DOM.
*
* ## Example
* ```html
@@ -52,6 +54,11 @@ export const Tooltip = function(superClass) {
return this._tooltip;
}
disconnectedCallback() {
super.disconnectedCallback();
this._hideTooltip();
}
_tooltipChanged(newTooltip, oldTooltip) {
if (oldTooltip) {
this.removeEventListener('mouseenter', this._showTooltip);
-5
View File
@@ -61,11 +61,6 @@ class TpTooltipWrapper extends Tooltip(LitElement) {
return true;
}
disconnectedCallback() {
super.disconnectedCallback();
this._hideTooltip();
}
_setTooltipText(text, disabled) {
this.tooltip = disabled ? '' : text;
}