fix(mobile): capture the mouse pointer and clear stale gestures on pointerdown

A drag leaving the terminal surface dropped pointermove/pointerup without
pointer capture, stranding the gesture; a pointerup lost outside the
WebView could leave a tracked press latched until the next gesture.
This commit is contained in:
Brennan Benson
2026-07-29 19:26:40 -07:00
parent 52c749207a
commit 62d88abb98
@@ -101,6 +101,14 @@ export const TERMINAL_MOUSE_CLICK_DRAG_JS = `
targetSurface.addEventListener('pointerdown', function(e) {
if (e.pointerType !== 'mouse' || e.button !== 0) return;
if (dispatcherShouldBlockSurface() || !term) return;
// Why: a pointerup lost outside the WebView must not leave the previous
// gesture latched (tracking press with no release) when the next one lands.
if (mouseGesture) abandonMouseGesture();
// Why: mouse pointers have no implicit capture; without it a drag that
// leaves the surface drops pointermove/pointerup and strands the gesture.
try {
if (targetSurface.setPointerCapture) targetSurface.setPointerCapture(e.pointerId);
} catch (err) {}
mouseGesture = {
startX: e.clientX, startY: e.clientY,
lastX: e.clientX, lastY: e.clientY,