From bc57cb52f660208a101609ec7853a0326528b3f8 Mon Sep 17 00:00:00 2001 From: Zoltan Hawryluk Date: Fri, 18 Oct 2024 10:07:31 -0400 Subject: [PATCH] Remove mouseleave events because mouse users with tremors will have problems with them. --- js/modules/es4/tooltip.js | 11 ++++++----- js/modules/tooltip.js | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/js/modules/es4/tooltip.js b/js/modules/es4/tooltip.js index e8ba2682..95361e98 100755 --- a/js/modules/es4/tooltip.js +++ b/js/modules/es4/tooltip.js @@ -104,6 +104,12 @@ const tooltip = new (function() { this.show = (e) => { tooltipTarget = e.target; + const closestTooltipEl = tooltipTarget.closest('[data-tooltip]'); + + if (closestTooltipEl !== null) { + tooltipTarget = closestTooltipEl; + } + const text = tooltipTarget.dataset.tooltip; if (!text || (isTooltipVisible && tooltipBelongsTo === tooltipTarget)) { return; @@ -135,9 +141,6 @@ const tooltip = new (function() { tooltipStyle.top = `calc(${tooltipTargetRect.top + window.scrollY - tooltipHeight}px - 1em)` } - tooltipTarget.addEventListener('mouseleave', this.hide); - tooltipEl.addEventListener('mouseleave', this.hide); - tooltipEl.dispatchEvent( new CustomEvent('enable-show', { bubbles: true }) ); @@ -170,8 +173,6 @@ const tooltip = new (function() { } if (tooltipTarget) { - tooltipTarget.removeEventListener('mouseleave', this.hide); - tooltipEl.removeEventListener('mouseleave', this.hide); if (tooltipTarget.tagName === 'INPUT'){ tooltipTarget.removeAttribute('aria-describedby'); } diff --git a/js/modules/tooltip.js b/js/modules/tooltip.js index 2987a75a..a7f87d40 100755 --- a/js/modules/tooltip.js +++ b/js/modules/tooltip.js @@ -104,6 +104,12 @@ const tooltip = new function () { this.show = (e) => { tooltipTarget = e.target; + const closestTooltipEl = tooltipTarget.closest('[data-tooltip]'); + + if (closestTooltipEl !== null) { + tooltipTarget = closestTooltipEl; + } + const text = tooltipTarget.dataset.tooltip; if (!text || (isTooltipVisible && tooltipBelongsTo === tooltipTarget)) { return; @@ -135,9 +141,6 @@ const tooltip = new function () { tooltipStyle.top = `calc(${tooltipTargetRect.top + window.scrollY - tooltipHeight}px - 1em)` } - tooltipTarget.addEventListener('mouseleave', this.hide); - tooltipEl.addEventListener('mouseleave', this.hide); - tooltipEl.dispatchEvent( new CustomEvent('enable-show', { bubbles: true }) ); @@ -170,8 +173,6 @@ const tooltip = new function () { } if (tooltipTarget) { - tooltipTarget.removeEventListener('mouseleave', this.hide); - tooltipEl.removeEventListener('mouseleave', this.hide); if (tooltipTarget.tagName === 'INPUT'){ tooltipTarget.removeAttribute('aria-describedby'); }