From 6bb6be011c95f1830865550763d3e40486e1a6f6 Mon Sep 17 00:00:00 2001 From: Sli Date: Wed, 14 May 2025 15:02:46 +0200 Subject: [PATCH] Fix tooltip fading transitions and synchronize additional attributes --- com/static/bundled/com/components/ics-calendar-index.ts | 5 ++--- com/static/com/components/ics-calendar.scss | 9 +++++++-- core/static/bundled/core/tooltips-index.ts | 8 ++++++-- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/com/static/bundled/com/components/ics-calendar-index.ts b/com/static/bundled/com/components/ics-calendar-index.ts index 6347cc22..ad85280a 100644 --- a/com/static/bundled/com/components/ics-calendar-index.ts +++ b/com/static/bundled/com/components/ics-calendar-index.ts @@ -319,7 +319,7 @@ export class IcsCalendar extends inheritHtmlElement("div") { click: async (event: Event) => { const button = event.target as HTMLButtonElement; button.classList.add("text-copy"); - button.setAttribute("tooltip-class", "text-copy"); + button.setAttribute("tooltip-class", "calendar-copy-tooltip"); if (!button.hasAttribute("tooltip-position")) { button.setAttribute("tooltip-position", "top"); } @@ -334,11 +334,10 @@ export class IcsCalendar extends inheritHtmlElement("div") { ).toString(), ); setTimeout(() => { - button.setAttribute("tooltip-class", "text-copied"); + button.setAttribute("tooltip-class", "calendar-copy-tooltip text-copied"); button.classList.remove("text-copied"); button.classList.add("text-copied"); button.classList.remove("text-copy"); - button.removeAttribute("tooltip"); }, 1500); }, }, diff --git a/com/static/com/components/ics-calendar.scss b/com/static/com/components/ics-calendar.scss index 4aa002b4..74d04053 100644 --- a/com/static/com/components/ics-calendar.scss +++ b/com/static/com/components/ics-calendar.scss @@ -117,7 +117,6 @@ ics-calendar { transition: 500ms ease-out; margin-right: 0.5rem; } -} .fc .fc-helpButton-button { border-radius: 70%; @@ -136,6 +135,12 @@ ics-calendar { } } -.tooltip.text-copy { +.tooltip.calendar-copy-tooltip { opacity: 1; + transition: opacity 500ms ease-in; } + +.tooltip.calendar-copy-tooltip.text-copied { + opacity: 0; + transition: opacity 500ms ease-out; +} \ No newline at end of file diff --git a/core/static/bundled/core/tooltips-index.ts b/core/static/bundled/core/tooltips-index.ts index 0b68a385..e315a7b2 100644 --- a/core/static/bundled/core/tooltips-index.ts +++ b/core/static/bundled/core/tooltips-index.ts @@ -110,7 +110,9 @@ function tooltipMouseover(event: MouseEvent) { }); }); - document.body.append(tooltip); + if (!tooltip.isConnected) { + document.body.append(tooltip); + } } function tooltipMouseout(event: MouseEvent) { @@ -138,6 +140,8 @@ new MutationObserver((mutations: MutationRecord[]) => { target.addEventListener("mouseout", tooltipMouseout); if (target.matches(":hover")) { target.dispatchEvent(new Event("mouseover", { bubbles: true })); + } else { + target.dispatchEvent(new Event("mouseout", { bubbles: true })); } } else if (tooltips.has(target)) { // Remove corresponding tooltip @@ -147,7 +151,7 @@ new MutationObserver((mutations: MutationRecord[]) => { } }).observe(document.body, { attributes: true, - attributeFilter: ["tooltip"], + attributeFilter: ["tooltip", "tooltip-class", "toolitp-position"], subtree: true, });