Skip to content

Commit

Permalink
fix(tooltip): Tooltips stay visible on mobile Firefox
Browse files Browse the repository at this point in the history
It looks like mobile Firefox triggers a touchmove event around the same
time as a contextmenu event which caused the hide() function to trigger.
Changing it to a scroll event instead of touchmove fixes the behavior so
that a user touching a tooltipped element and starts scrolling the page
does not cause the tooltip to appear.
  • Loading branch information
mlaursen committed Mar 18, 2022
1 parent f318ecf commit 7039fef
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/tooltip/src/useTooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -517,10 +517,10 @@ export function useTooltip<E extends HTMLElement>({
return;
}

window.addEventListener("touchmove", hide, true);
window.addEventListener("scroll", hide, true);
window.addEventListener("touchend", hide, true);
return () => {
window.removeEventListener("touchmove", hide, true);
window.removeEventListener("scroll", hide, true);
window.removeEventListener("touchend", hide, true);
};
}, [hide, initiatedBy, setVisible]);
Expand Down

0 comments on commit 7039fef

Please sign in to comment.