From 5970340a17b11c8122bb9273b2ed8b9f073e066c Mon Sep 17 00:00:00 2001 From: Nils Schneider Date: Sun, 19 Oct 2025 23:26:27 +0200 Subject: [PATCH] frontend: fix regression when pointer leaves document while dragging --- frontend/src/skeuomorphic_ws.jsx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/frontend/src/skeuomorphic_ws.jsx b/frontend/src/skeuomorphic_ws.jsx index c94120f..bba8790 100644 --- a/frontend/src/skeuomorphic_ws.jsx +++ b/frontend/src/skeuomorphic_ws.jsx @@ -210,6 +210,15 @@ const useDocumentDrag = ({ if (!state || state.pointerId !== pointerId) { return; } + const capturedTarget = state.capturedTarget; + if (capturedTarget && typeof capturedTarget.releasePointerCapture === 'function') { + try { + capturedTarget.releasePointerCapture(pointerId); + } catch ( + // eslint-disable-next-line no-empty + error + ) {} + } dragStateRef.current = null; setDraggingId((current) => (current === state.docId ? null : current)); syncLayoutSnapshot(); @@ -246,6 +255,15 @@ const useDocumentDrag = ({ } bringToFront(docId); + const capturedTarget = event.currentTarget instanceof HTMLElement ? event.currentTarget : null; + if (capturedTarget && typeof capturedTarget.setPointerCapture === 'function') { + try { + capturedTarget.setPointerCapture(event.pointerId); + } catch ( + // eslint-disable-next-line no-empty + error + ) {} + } dragStateRef.current = { docId, pointerId: event.pointerId, @@ -259,6 +277,7 @@ const useDocumentDrag = ({ width: docWidth, height: docHeight, scale: baseScale, + capturedTarget, }; setDraggingId(docId); },