Skip to content

Commit e11495e

Browse files
committed
fix: dont start selection in case of back gesture
1 parent fae81cd commit e11495e

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

src/components/terminal/terminalTouchSelection.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,11 @@ export default class TerminalTouchSelection {
240240
return;
241241
}
242242

243+
// Check if touch is near screen edge (likely Android back gesture)
244+
if (this.isEdgeGesture(touch)) {
245+
return;
246+
}
247+
243248
// Clear any existing tap-hold timeout
244249
if (this.tapHoldTimeout) {
245250
clearTimeout(this.tapHoldTimeout);
@@ -269,6 +274,19 @@ export default class TerminalTouchSelection {
269274
const touch = event.touches[0];
270275
const deltaX = Math.abs(touch.clientX - this.touchStartPos.x);
271276
const deltaY = Math.abs(touch.clientY - this.touchStartPos.y);
277+
const horizontalDelta = touch.clientX - this.touchStartPos.x;
278+
279+
// Check if this looks like a back gesture (started near edge and moving horizontally inward)
280+
if (this.isEdgeGesture(this.initialTouchPos) &&
281+
Math.abs(horizontalDelta) > deltaY &&
282+
deltaX > this.options.moveThreshold) {
283+
// This looks like a back gesture, cancel selection
284+
if (this.tapHoldTimeout) {
285+
clearTimeout(this.tapHoldTimeout);
286+
this.tapHoldTimeout = null;
287+
}
288+
return;
289+
}
272290

273291
// If significant movement, cancel tap-hold
274292
if (
@@ -1141,6 +1159,26 @@ export default class TerminalTouchSelection {
11411159
return Math.sqrt(dx * dx + dy * dy);
11421160
}
11431161

1162+
/**
1163+
* Check if touch is likely an Android back gesture (starts near screen edge)
1164+
*/
1165+
isEdgeGesture(touch) {
1166+
const edgeThreshold = 30; // pixels from screen edge
1167+
const screenWidth = window.innerWidth;
1168+
1169+
// Check if touch starts near left edge (most common for back gesture)
1170+
if (touch.clientX <= edgeThreshold) {
1171+
return true;
1172+
}
1173+
1174+
// Check if touch starts near right edge (for RTL languages or right-handed back gesture)
1175+
if (touch.clientX >= screenWidth - edgeThreshold) {
1176+
return true;
1177+
}
1178+
1179+
return false;
1180+
}
1181+
11441182
destroy() {
11451183
// Clear selection
11461184
this.forceClearSelection();

0 commit comments

Comments
 (0)