Skip to content

Commit

Permalink
Remove mouseleave events because mouse users with tremors will have p…
Browse files Browse the repository at this point in the history
…roblems with them.
  • Loading branch information
zoltan-dulac committed Oct 18, 2024
1 parent 9b80b9e commit bc57cb5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
11 changes: 6 additions & 5 deletions js/modules/es4/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 })
);
Expand Down Expand Up @@ -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');
}
Expand Down
11 changes: 6 additions & 5 deletions js/modules/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 })
);
Expand Down Expand Up @@ -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');
}
Expand Down

0 comments on commit bc57cb5

Please sign in to comment.