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
This commit is contained in:
Kristina 2025-01-28 08:00:15 -06:00 committed by GitHub
parent 0bf31c14a7
commit 52a6c27d99
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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', {