tracker: fix remote control clicks on svg

This commit is contained in:
nick-delirium 2025-03-26 17:41:37 +01:00 committed by Delirium
parent ac0ccb2169
commit eb610d1c21
6 changed files with 20 additions and 6 deletions

View file

@ -1,7 +1,7 @@
{
"name": "@openreplay/tracker-assist",
"description": "Tracker plugin for screen assistance through the WebRTC",
"version": "11.0.2-beta.1",
"version": "11.0.2",
"keywords": [
"WebRTC",
"assistance",

View file

@ -63,8 +63,21 @@ export default class Mouse {
click(pos: XY) {
const el = document.elementFromPoint(pos[0], pos[1])
if (el instanceof HTMLElement) {
el.click()
if (el instanceof HTMLElement || el instanceof SVGElement) {
try {
const clickEvent = new MouseEvent('click', {
bubbles: true,
cancelable: true,
view: window,
clientX: pos[0],
clientY: pos[1]
})
el.dispatchEvent(clickEvent)
} catch (e) {
console.error(e);
// @ts-ignore
el.click && el.click()
}
el.focus()
return el
}

View file

@ -115,7 +115,7 @@ export default class RemoteControl {
move = (id, xy) => {
return id === this.agentID && this.mouse?.move(xy)
}
private focused: HTMLElement | null = null
private focused: HTMLElement | SVGElement | null = null
click = (id, xy) => {
if (id !== this.agentID || !this.mouse) { return }
this.focused = this.mouse.click(xy)
@ -132,7 +132,9 @@ export default class RemoteControl {
setInputValue.call(this.focused, value)
const ev = new Event('input', { bubbles: true,})
this.focused.dispatchEvent(ev)
// @ts-ignore
} else if (this.focused.isContentEditable) {
// @ts-ignore
this.focused.innerText = value
}
}

View file

@ -1 +1 @@
export const pkgVersion = "11.0.2-beta.1";
export const pkgVersion = "11.0.2";

View file

@ -881,7 +881,6 @@ export default class App {
}
this.emptyBatchCounter = 0
console.log('messages', this.messages.join(', '))
try {
requestIdleCb(() => {