Skip to content

Commit c9883f5

Browse files
committed
Fix mobile tooltip
1 parent 8bd36fa commit c9883f5

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

gui/src/components/commons/Tooltip.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -359,13 +359,10 @@ export function DrawerTooltip({
359359
}
360360
};
361361

362-
const touchEnd = (e: MouseEvent | TouchEvent) => {
363-
if (Date.now() - touchTimestamp.current > TOOLTIP_DELAY) {
364-
// open drawer
365-
e.preventDefault(); // cancel the click event
362+
const touchEnd = () => {
363+
if (Date.now() - touchTimestamp.current < TOOLTIP_DELAY) {
366364
clearTimeout(touchTimeout.current);
367-
368-
open();
365+
close();
369366
}
370367
};
371368

@@ -394,12 +391,14 @@ export function DrawerTooltip({
394391

395392
elem.addEventListener('touchstart', touchStart);
396393
elem.addEventListener('touchend', touchEnd);
394+
elem.addEventListener('touchcancel', touchEnd);
397395

398396
return () => {
399397
elem.removeEventListener('scroll', scroll);
400398

401399
elem.removeEventListener('touchstart', touchStart);
402400
elem.removeEventListener('touchend', touchEnd);
401+
elem.removeEventListener('touchcancel', touchEnd);
403402
clearTimeout(touchTimeout.current);
404403
};
405404
}

0 commit comments

Comments
 (0)