fix(mobile): add tap threshold to terminal touch handler

touchmove fires on any 1px finger drift, marking didScroll=true and
skipping the tap handler (which refocuses terminal/CJK input). On
iPad's large touch surface and phones with imprecise taps, this makes
terminal tap unreliable — cjkActive gets stuck true, blocking all
input (CJK and paste).

Add 8px TAP_THRESHOLD: finger movement under 8px is still a tap.
Also add touch-action:none on .touch-device .terminal-container
so the browser doesn't consume touch events before our JS handler.
This commit is contained in:
Teigen
2026-06-17 23:40:21 +08:00
parent 47359e4002
commit b1c4330680
3 changed files with 35 additions and 10 deletions
+8 -2
View File
@@ -162,6 +162,10 @@ const CjkInput = (() => {
if (!_textarea.classList.contains('cjk-input-visible')) {
window.cjkActive = false;
}
// Reset composing state — some IMEs fire compositionstart without a
// matching compositionend, leaving _composing stuck true and blocking
// all subsequent input events.
_composing = false;
};
_textarea.addEventListener('mousedown', _listeners.mousedown);
_textarea.addEventListener('focus', _listeners.focus);
@@ -214,8 +218,10 @@ const CjkInput = (() => {
return;
}
// Below: only when NOT composing (composing keystrokes belong to IME)
if (_composing) return;
// Below: only when NOT composing (composing keystrokes belong to IME).
// Also check isComposing/keyCode 229 — the first keydown of a CJK
// sequence arrives BEFORE compositionstart, so _composing is still false.
if (_composing || e.isComposing || e.keyCode === 229) return;
// Backspace: forward to PTY when no real text in textarea
if (e.key === 'Backspace' && _isEffectivelyEmpty()) {