elbe-ui 0.4.11 → 0.4.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ui/theme/theme.js +9 -1
- package/package.json +1 -1
package/dist/ui/theme/theme.js
CHANGED
|
@@ -36,7 +36,6 @@ export function ElbeTheme(p) {
|
|
|
36
36
|
function _addTooltip() {
|
|
37
37
|
return useEffect(() => {
|
|
38
38
|
const _gap = 8;
|
|
39
|
-
console.log("add tooltip");
|
|
40
39
|
const onHover = (e) => {
|
|
41
40
|
var _a;
|
|
42
41
|
const target = (_a = e.target) === null || _a === void 0 ? void 0 : _a.closest("[data-tooltip]");
|
|
@@ -63,6 +62,15 @@ function _addTooltip() {
|
|
|
63
62
|
left = window.innerWidth - tooltip.offsetWidth - _gap;
|
|
64
63
|
tooltip.style.top = `${top}px`;
|
|
65
64
|
tooltip.style.left = `${left}px`;
|
|
65
|
+
// remove tooltip when target is removed or mouse leaves
|
|
66
|
+
const observer = new MutationObserver(() => {
|
|
67
|
+
if (!document.body.contains(target) ||
|
|
68
|
+
target === null) {
|
|
69
|
+
tooltip.remove();
|
|
70
|
+
observer.disconnect();
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
66
74
|
target.addEventListener("mouseleave", () => tooltip.remove(), {
|
|
67
75
|
once: true,
|
|
68
76
|
});
|