Fix iOS keyboard dismissal - don't steal focus with terminal.focus()

This commit is contained in:
GitHub Copilot
2026-01-28 07:49:22 +00:00
parent 63c49f385f
commit fb2bc46ecb
2 changed files with 10 additions and 15 deletions
File diff suppressed because one or more lines are too long
+5 -10
View File
@@ -454,24 +454,19 @@ class WebTerminal {
// Focus textarea on touch/click to show mobile keyboard // Focus textarea on touch/click to show mobile keyboard
// iOS requires focus() to be called synchronously within the gesture // iOS requires focus() to be called synchronously within the gesture
this.element.addEventListener("touchend", (e) => { // Don't call terminal.focus() as it steals focus and dismisses keyboard
// Only respond to single touch on terminal area const focusTextarea = () => {
if (e.target === textarea || e.target === this.element || this.element.contains(e.target as Node)) {
this.mobileInput?.focus(); this.mobileInput?.focus();
} };
}, { passive: true });
this.element.addEventListener("click", () => { this.element.addEventListener("touchend", focusTextarea, { passive: true });
this.mobileInput?.focus(); this.element.addEventListener("click", focusTextarea);
this.terminal.focus();
});
} }
/** Focus the mobile input to show keyboard */ /** Focus the mobile input to show keyboard */
private focusMobileInput(): void { private focusMobileInput(): void {
// For programmatic focus (not from user gesture), this may not show keyboard on iOS // For programmatic focus (not from user gesture), this may not show keyboard on iOS
this.mobileInput?.focus(); this.mobileInput?.focus();
this.terminal.focus();
} }
/** Wait for fonts to be loaded */ /** Wait for fonts to be loaded */