Node.js based forum software built for the modern web
fix: #13484, clear tooltip if cursor leaves link
Barış Soner Uşaklı0ebb31fe8775
diff --git a/public/src/client/topic.js b/public/src/client/topic.jsindex 0480d3844c..3bb50a5da5 100644--- a/public/src/client/topic.js+++ b/public/src/client/topic.js@@ -309,12 +309,14 @@ define('forum/topic', [}let timeoutId = 0;let destroyed = false;+ let cursorOnPreviewTooltip = false;const postCache = {};function destroyTooltip() {clearTimeout(timeoutId);timeoutId = 0;$('#post-tooltip').remove();destroyed = true;+ cursorOnPreviewTooltip = false;}function onClickOutside(ev) {@@ -328,6 +330,14 @@ define('forum/topic', [$('[component="topic"]').on('mouseenter', 'a[component="post/parent"], [component="post/parent/content"] a,[component="post/content"] a, [component="topic/event"] a', async function () {const link = $(this);link.one('mouseleave', function () {+ setTimeout(() => {+ // If the mouse leaves the link and it's not on a tooltip, destroy the tooltip after a short delay+ if (!cursorOnPreviewTooltip) {+ destroyTooltip();+ }+ }, 300);++ // if mouse leaves the link before the tooltip is rendered, clear the timeoutif (timeoutId > 0) {clearTimeout(timeoutId);timeoutId = 0;@@ -352,7 +362,9 @@ define('forum/topic', [const linkRect = link.offset();const { top } = link.get(0).getBoundingClientRect();const dropup = top > window.innerHeight / 2;-+ tooltip.on('mouseenter', function () {+ onPreviewTooltip = true;+ });tooltip.one('mouseleave', destroyTooltip);$(window).off('click', onClickOutside).one('click', onClickOutside);tooltip.css({