From df51a1e140c1e1af440a7cfd0a7d5ea42832a004 Mon Sep 17 00:00:00 2001 From: lalalasyun Date: Mon, 11 May 2026 01:03:09 +0900 Subject: [PATCH] fix: prevent hidden textarea focus scroll --- packages/@wterm/dom/src/input.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/@wterm/dom/src/input.ts b/packages/@wterm/dom/src/input.ts index 5e2bfce..0ada32f 100644 --- a/packages/@wterm/dom/src/input.ts +++ b/packages/@wterm/dom/src/input.ts @@ -74,8 +74,10 @@ export class InputHandler { this.textarea.setAttribute("tabindex", "0"); this.textarea.setAttribute("aria-hidden", "true"); const s = this.textarea.style; - s.position = "absolute"; - s.left = "-9999px"; + // Keep the focus target in the viewport so mobile/Chromium browsers do not + // try to scroll the page to reveal an off-screen textarea while typing. + s.position = "fixed"; + s.left = "0"; s.top = "0"; s.width = "1px"; s.height = "1px"; @@ -145,7 +147,7 @@ export class InputHandler { if (sel && sel.toString().length > 0) return; } if ((e.metaKey || e.ctrlKey) && e.key === "v") { - this.textarea.focus(); + this.textarea.focus({ preventScroll: true }); return; } if (e.metaKey && !e.ctrlKey) {