From 52a6c27d99e5d984032cc36802e7cc4dcd2bf79d Mon Sep 17 00:00:00 2001 From: Kristina Date: Tue, 28 Jan 2025 08:00:15 -0600 Subject: [PATCH] VizTooltip: Check useragent to perform consistently on all mobile devices (#99655) * Add useragent check to be comprehensive * move check outside function and add hopefully clarifying comment --- .../src/components/uPlot/plugins/TooltipPlugin2.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/grafana-ui/src/components/uPlot/plugins/TooltipPlugin2.tsx b/packages/grafana-ui/src/components/uPlot/plugins/TooltipPlugin2.tsx index cb0527a9961..b2e142d6a64 100644 --- a/packages/grafana-ui/src/components/uPlot/plugins/TooltipPlugin2.tsx +++ b/packages/grafana-ui/src/components/uPlot/plugins/TooltipPlugin2.tsx @@ -108,6 +108,8 @@ const maybeZoomAction = (e?: MouseEvent | null) => e != null && !e.ctrlKey && !e const getDataLinksFallback: GetDataLinksCallback = () => []; +const userAgentIsMobile = /Android|iPhone|iPad/i.test(navigator.userAgent); + /** * @alpha */ @@ -666,8 +668,9 @@ export const TooltipPlugin2 = ({ // if not viaSync, re-dispatch real event if (event != null) { - // we expect to re-dispatch mousemove, but on mobile we'll get mouseup or click - const isMobile = event.type !== 'mousemove'; + // we expect to re-dispatch mousemove, but may have a different event type, so create a mousemove event and fire that instead + // this doesn't work for every mobile device, so fall back to checking the useragent as well + const isMobile = event.type !== 'mousemove' || userAgentIsMobile; if (isMobile) { event = new MouseEvent('mousemove', {