Make sure all consumers of the tooltip mixin clean up when unmounted.
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@tp/tp-tooltip",
|
"name": "@tp/tp-tooltip",
|
||||||
"version": "1.0.0",
|
"version": "1.1.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "tp-tooltip.js",
|
"main": "tp-tooltip.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import './tp-tooltip.js';
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Elements implementing this mixin are able to show tooltip on mouse over.
|
* 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
|
* ## Example
|
||||||
* ```html
|
* ```html
|
||||||
@@ -52,6 +54,11 @@ export const Tooltip = function(superClass) {
|
|||||||
return this._tooltip;
|
return this._tooltip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
disconnectedCallback() {
|
||||||
|
super.disconnectedCallback();
|
||||||
|
this._hideTooltip();
|
||||||
|
}
|
||||||
|
|
||||||
_tooltipChanged(newTooltip, oldTooltip) {
|
_tooltipChanged(newTooltip, oldTooltip) {
|
||||||
if (oldTooltip) {
|
if (oldTooltip) {
|
||||||
this.removeEventListener('mouseenter', this._showTooltip);
|
this.removeEventListener('mouseenter', this._showTooltip);
|
||||||
|
|||||||
@@ -61,11 +61,6 @@ class TpTooltipWrapper extends Tooltip(LitElement) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
disconnectedCallback() {
|
|
||||||
super.disconnectedCallback();
|
|
||||||
this._hideTooltip();
|
|
||||||
}
|
|
||||||
|
|
||||||
_setTooltipText(text, disabled) {
|
_setTooltipText(text, disabled) {
|
||||||
this.tooltip = disabled ? '' : text;
|
this.tooltip = disabled ? '' : text;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user