mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-04 22:49:41 +02:00
fix(mobile): keep keyboard focus taps non-activating
This commit is contained in:
@@ -650,6 +650,7 @@ Object.assign(CodemanApp.prototype, {
|
||||
|
||||
let didScroll = false; // track whether touchmove fired (tap vs scroll)
|
||||
let touchStartY = 0;
|
||||
let tapCanActivateTerminal = false;
|
||||
const TAP_THRESHOLD = 8; // px — ignore micro-drift to distinguish tap from scroll
|
||||
container.addEventListener(
|
||||
'touchstart',
|
||||
@@ -662,6 +663,7 @@ Object.assign(CodemanApp.prototype, {
|
||||
pixelAccum = 0;
|
||||
isTouching = true;
|
||||
didScroll = false;
|
||||
tapCanActivateTerminal = this._shouldForwardMobileTapToApp();
|
||||
lastTime = 0;
|
||||
if (scrollFrame) {
|
||||
cancelAnimationFrame(scrollFrame);
|
||||
@@ -737,9 +739,13 @@ Object.assign(CodemanApp.prototype, {
|
||||
if (touch) {
|
||||
this._suppressTrustedTapMouseEvents();
|
||||
}
|
||||
if (touch && mouseTrackingOn) {
|
||||
if (touch && tapCanActivateTerminal && mouseTrackingOn) {
|
||||
this._dispatchSyntheticTerminalClick(touch.clientX, touch.clientY);
|
||||
} else if (touch && this._sessionUsesServerMouseStrip()) {
|
||||
} else if (
|
||||
touch &&
|
||||
tapCanActivateTerminal &&
|
||||
this._sessionUsesServerMouseStrip()
|
||||
) {
|
||||
// The server strips mouse-tracking DECSETs from claude/codex/gemini
|
||||
// output (isAltScreenStripMode, session.ts) so the wheel keeps
|
||||
// scrolling scrollback — which leaves THIS xterm permanently at
|
||||
@@ -759,6 +765,7 @@ Object.assign(CodemanApp.prototype, {
|
||||
this.terminal.focus();
|
||||
}
|
||||
}
|
||||
tapCanActivateTerminal = false;
|
||||
},
|
||||
{ passive: true }
|
||||
);
|
||||
@@ -3363,6 +3370,26 @@ Object.assign(CodemanApp.prototype, {
|
||||
} catch {}
|
||||
},
|
||||
|
||||
/**
|
||||
* A tap that opens the phone keyboard is focus-only. Forwarding that same
|
||||
* gesture as a mouse click would activate the highlighted CLI menu option.
|
||||
* Once the keyboard and terminal input were already active at touchstart,
|
||||
* later taps may intentionally position the cursor or select a TUI row.
|
||||
*/
|
||||
_shouldForwardMobileTapToApp() {
|
||||
const keyboardVisible =
|
||||
(typeof KeyboardHandler !== 'undefined' && KeyboardHandler.keyboardVisible) ||
|
||||
document.body?.classList?.contains('keyboard-visible');
|
||||
if (!keyboardVisible) return false;
|
||||
|
||||
const active = document.activeElement;
|
||||
return (
|
||||
active === this.terminal?.textarea ||
|
||||
active?.classList?.contains('xterm-helper-textarea') ||
|
||||
active?.id === 'cjkInput'
|
||||
);
|
||||
},
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════
|
||||
// Synthetic tap → mouse report
|
||||
// ═══════════════════════════════════════════════════════════════
|
||||
|
||||
Reference in New Issue
Block a user