Skip to content

fix(mobile): keep the android keyboard closed when you scroll or swipe the terminal - #32038

Merged
AmoabaKelvin merged 1 commit into
mainfrom
mobile-terminal-touch-keyboard
Oct 22, 2026
Merged

AmoabaKelvin merged 1 commit into
mainfrom
mobile-terminal-touch-keyboard

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​75 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​75
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​19 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​19

ELI5

On Android, after you close the keyboard with Back, scrolling or swiping the terminal kept popping it back up. Now a keyboard you close stays closed until you tap something that opens it.

What Changed

  • Before (Android): Back hides the keyboard but the text field stays focused. In the Orca page's WebView, the next touch on the terminal (scroll, swipe, flick, or a touch that stops a coasting scroll) raised the keyboard again. This happened in both live input and buffered command mode, and in buffered mode even a plain tap brought it back.
  • After: when the keyboard closes on Android, the page blurs the focused field (Keyboard.dismiss(), the same dismissal the app uses elsewhere), so terminal touches can't bring the keyboard back. With the keyboard open, scrolling, swiping, flicking and tapping keep it open, as before.
  • Mechanism: startBlurringOnKeyboardClose() in mobile/src/platform/keyboard-close-blur.web.ts subscribes to the page's keyboard close signal (the shell's reported keyboard height going to 0). The page entry starts it next to publishShellKeyboardSource. It does nothing on iOS.

Why

Root cause: on Android the field keeps focus after the system hides the keyboard, so the page's "a field is focused" state no longer matches "the keyboard is up". While a field is focused, the WebView raises the keyboard again on terminal touches. With the field blurred, the same gestures leave it closed (checked over CDP in the emulator). Blocking the terminal's own touch listeners or default touch handling did not stop the re-raise, so the fix has to end the stale focus, not change the gesture code.

Left as is:

  • A deliberate tap on the terminal in live input mode still opens the keyboard. That is documented behaviour (mobile/mobile-terminal-direct-input-default.md); making it optional is [Feature][Mobile]: Option to stop a plain tap on the terminal from opening the keyboard #17730.
  • The existing focus-time blur-then-refocus fallback in terminal-live-input.ts stays. Native screens and shells from before keyboard-height reports never send a close the page can see, and that fallback is still what reopens the keyboard for them.
  • Native screens are unchanged. Their terminal is a separate WebView, so a stale field focus there doesn't re-raise the keyboard.
  • iOS doesn't have the bug. Its dismiss already blurs, and the recordings below show both states correct before and after.

Linked Issue

Fixes #31279 (Linear STA-11437)

Visual Proof

Android emulator (release 0.0.58 shell, page served by a dev desktop). Each take: keyboard open, then scroll, swipe, flick and tap (it should stay open); close with Back; then scroll down, scroll up, flick and stop the coast, and swipe sideways (it should stay closed).

Android, before: the keyboard pops back up after every gesture in the closed state.

(screenshot removed: contained real product data)

Android, after: it stays closed.

(screenshot removed: contained real product data)

iOS simulator (same sequence; it closes with the dismiss key). No change: both states were already correct.

iOS, before:

(screenshot removed: contained real product data)

iOS, after:

(screenshot removed: contained real product data)

Testing

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • mobile/src/platform/keyboard-close-blur.web.test.ts runs react-native-web's real Keyboard and TextInputState. A field focused on Android loses focus when the shell reports the keyboard closed; on iOS it keeps focus. The Android case fails without the fix.

  • Android emulator, driven over WebView CDP and dumpsys input_method:

    • Live mode: after Back, swipes down, up and sideways, a flick, and a flick then a touch to stop it all leave the keyboard closed. A deliberate tap still opens it.
    • Buffered mode: after Back, swipes, flick and stop, and taps all leave it closed.
    • With the keyboard open, every gesture keeps it open.
    • Switching buffered → live with the keyboard open keeps it open (3 of 3 runs).
  • Local checks: focused mobile tests, mobile tsc, the tests-typecheck ratchet, check:code-quality:changed, check:react-doctor:changed.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Mobile only, and only in the over-the-air page. Desktop, SSH and folder workspaces are unaffected. Mixed versions: older shells never report a close, so they behave as on main.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…nal touches

Android's Back hides the IME but leaves its field focused, and the page's WebView
raised it again on the next terminal scroll, swipe or flick.

Fixes #31279
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Mobile TUI terminal touch and scroll gestures unexpectedly open or collapse the soft keyboard

1 participant