From 8d269c838d629e2610b6c0acc22373f61c37cfd5 Mon Sep 17 00:00:00 2001 From: Saul-Mirone Date: Mon, 30 Dec 2024 14:59:10 +0000 Subject: [PATCH] fix(editor): touch event browser copability (#9437) Fix: https://toeverything.sentry.io/issues/6180659644/events/82bf2e7bb8fc4ad69678261522b7fdf3/ --- .../affine/data-view/src/core/utils/wc-dnd/sensors/mouse.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/blocksuite/affine/data-view/src/core/utils/wc-dnd/sensors/mouse.ts b/blocksuite/affine/data-view/src/core/utils/wc-dnd/sensors/mouse.ts index e3d8a40d3e..2176a5bb6d 100644 --- a/blocksuite/affine/data-view/src/core/utils/wc-dnd/sensors/mouse.ts +++ b/blocksuite/affine/data-view/src/core/utils/wc-dnd/sensors/mouse.ts @@ -74,8 +74,12 @@ export function hasViewportRelativeCoordinates( return 'clientX' in event && 'clientY' in event; } +function isTouchEvent(event: Event): event is TouchEvent { + return 'TouchEvent' in globalThis && event instanceof TouchEvent; +} + const getEventCoordinates = (event: Event) => { - if (event instanceof TouchEvent) { + if (isTouchEvent(event)) { if (event.touches && event.touches.length) { const touch = event.touches[0]; if (!touch) return;