From 2cfbfd594c24385d4937835d1186533e95f6259e Mon Sep 17 00:00:00 2001 From: Antonio Villegas Date: Sat, 10 Feb 2024 02:12:56 +0100 Subject: [PATCH] Make properties x and y optional in mouseInteractionParam (#1375) * Make properties x and y optional in mouseInteractionParam The event representing a mouse interaction of focus an element does not include the properties x and y. Thus, they must be defined as optional. * Fix typings --- packages/rrweb/src/replay/index.ts | 6 +++--- packages/types/src/index.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/rrweb/src/replay/index.ts b/packages/rrweb/src/replay/index.ts index 1febcc401b..ee493fec0e 100644 --- a/packages/rrweb/src/replay/index.ts +++ b/packages/rrweb/src/replay/index.ts @@ -1161,8 +1161,8 @@ export class Replayer { this.lastMouseDownEvent = null; } this.mousePos = { - x: d.x, - y: d.y, + x: d.x || 0, + y: d.y || 0, id: d.id, debugData: d, }; @@ -1171,7 +1171,7 @@ export class Replayer { // don't draw a trail as user has lifted finger and is placing at a new point this.tailPositions.length = 0; } - this.moveAndHover(d.x, d.y, d.id, isSync, d); + this.moveAndHover(d.x || 0, d.y || 0, d.id, isSync, d); if (d.type === MouseInteractions.Click) { /* * don't want target.click() here as could trigger an iframe navigation diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index d4584847ee..c41d3e97ff 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -417,8 +417,8 @@ export type CanvasArg = type mouseInteractionParam = { type: MouseInteractions; id: number; - x: number; - y: number; + x?: number; + y?: number; pointerType?: PointerTypes; };