frontend: fix regression when pointer leaves document while dragging
This commit is contained in:
@@ -210,6 +210,15 @@ const useDocumentDrag = ({
|
|||||||
if (!state || state.pointerId !== pointerId) {
|
if (!state || state.pointerId !== pointerId) {
|
||||||
return;
|
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;
|
dragStateRef.current = null;
|
||||||
setDraggingId((current) => (current === state.docId ? null : current));
|
setDraggingId((current) => (current === state.docId ? null : current));
|
||||||
syncLayoutSnapshot();
|
syncLayoutSnapshot();
|
||||||
@@ -246,6 +255,15 @@ const useDocumentDrag = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
bringToFront(docId);
|
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 = {
|
dragStateRef.current = {
|
||||||
docId,
|
docId,
|
||||||
pointerId: event.pointerId,
|
pointerId: event.pointerId,
|
||||||
@@ -259,6 +277,7 @@ const useDocumentDrag = ({
|
|||||||
width: docWidth,
|
width: docWidth,
|
||||||
height: docHeight,
|
height: docHeight,
|
||||||
scale: baseScale,
|
scale: baseScale,
|
||||||
|
capturedTarget,
|
||||||
};
|
};
|
||||||
setDraggingId(docId);
|
setDraggingId(docId);
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user