Fix iOS keyboard dismissal - don't steal focus with terminal.focus()
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -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 */
|
||||||
|
|||||||
Reference in New Issue
Block a user