Skip to content

Commit b266575

Browse files
committed
use mouseover instead of mouseenter
1 parent 462257d commit b266575

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

web_src/js/modules/tippy.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,14 @@ function attachTooltip(target, content = null) {
5656
}
5757

5858
/**
59-
* creating tooltip tippy instance is expensive, so we only create it when the user hovers over the element
59+
* Creating tooltip tippy instance is expensive, so we only create it when the user hovers over the element
60+
* According to https://www.w3.org/TR/DOM-Level-3-Events/#events-mouseevent-event-order , mouseover event is fired before mouseenter event
61+
* Some old browsers like Pale Moon doesn't support "mouseenter(capture)"
62+
* The tippy by default uses "mouseenter" event to show, so we use "mouseover" event to switch to tippy
6063
* @param e {Event}
6164
*/
62-
function lazyTooltipOnMouseEnter(e) {
63-
e.target.removeEventListener('mouseenter', lazyTooltipOnMouseEnter, true);
65+
function lazyTooltipOnMouseHover(e) {
66+
e.target.removeEventListener('mouseover', lazyTooltipOnMouseHover, true);
6467
attachTooltip(this);
6568
}
6669

@@ -83,7 +86,7 @@ function getTooltipContent(target) {
8386
function attachChildrenLazyTooltip(target) {
8487
// the selector must match the logic in getTippyTooltipContent
8588
for (const el of target.querySelectorAll('[data-tooltip-content], .tooltip[data-content]')) {
86-
el.addEventListener('mouseenter', lazyTooltipOnMouseEnter, true);
89+
el.addEventListener('mouseover', lazyTooltipOnMouseHover, true);
8790

8891
// meanwhile, if the element has no aria-label, use the tooltip content as aria-label
8992
if (!el.hasAttribute('aria-label')) {

0 commit comments

Comments
 (0)