You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(mobile): keep the cursor and keyboard when tapping an autocorrected word on Android - #36751
On Android, when Samsung Keyboard autocorrects a word and you tap it to fix it, the keyboard closes and Orca throws away the cursor. Now Orca keeps the cursor where you tapped and brings the keyboard straight back, so you can just backspace and retype that part of the word.
What Changed
Before: you mean "npx", typo "run the nlx tests", and autocorrect makes it "Run the next tests". Tap the word, the keyboard closes, the chat box drops, and there is no cursor. Tapping again does nothing. You have to tap after the word and backspace through it.
After: tap the word, the autocorrect menu still opens, the keyboard comes back right away, and the cursor is where you tapped. Backspace, type "px", done.
Mechanism (all in keyboard-close-blur.web.ts):
It records the last pointerdown and whether it landed on a text field (an input or textarea).
On an Android keyboard close within 1 s of a touch on the field, it does not blur. Instead, 50 ms later, it blurs and refocuses the same field and restores the selection. Android only reopens the keyboard for a new focus session, which is the same thing the terminal live input already does.
Any other keyboard close, like Back, still calls Keyboard.dismiss() as before.
Why
This is Orca-side, not a keyboard bug: plain Chrome on the same phone, with the same keyboard and the same tap, keeps the cursor. Orca loses it because of its own blur.
That blur from #32038 is still needed: after Back, a still-focused field lets the next terminal touch reopen the keyboard. But the hook treats every keyboard close as Back, and Chromium closes the keyboard itself to show the autocorrect menu. "Was the field just touched?" tells them apart (Back has no touch).
Alternatives tried or considered:
Only keep focus, don't reopen the keyboard. The cursor stays, but the keyboard stays closed, so you still can't type. It matches plain Chrome, but it doesn't fix the real annoyance.
Reopen on the next tap instead. Doesn't work: the tap that closes Chromium's menu never reaches the page. No pointer, click or selectionchange event fires (checked with an on-screen event log on the device).
spellcheck=false on the field. Tested: the underline and menu still appear.
Only blur for the terminal input. Needs a terminal-field check across the session dock. It's more coupling, and the chat box still wouldn't get its keyboard back.
Why a 1 s time window and not something cleaner:
Back can't be detected directly: the keyboard consumes it before the page sees anything.
A plain "the field was the last thing touched" flag (no timer) breaks a real case: tap the box, wait, then press Back, and the keyboard would wrongly come back.
On the test phone the autocorrect menu closes the keyboard about 370 ms after the tap, so 1 s leaves room on slower devices while a later Back still blurs. Happy to move or tune the constants if you prefer.
Each alternative was tried first in a plain Chrome test page on the same phone; only the refocus brought the keyboard back with the cursor in place.
Before (left, 1.4.245) vs After (right, this PR). Same phone, same steps, in sync.
CARETFIX_V3_nlx_BEFORE_AFTER_2026-10-31.mp4
Testing
Real device: Galaxy S24+ (Android 16, Samsung Keyboard), Android app 0.0.61 against desktop 1.4.245 on Windows, with this change built into the mobile page.
Autocorrected word ("nlx" to "next", "npx" to "next", "readme" to "reader"): tap it, the menu shows, the keyboard comes back with the cursor where tapped, and backspace/typing edits in place. Picking the original word from the menu still works.
Chat box: keyboard open, Back: the keyboard closes and stays closed. Tap the box: it opens normally.
oxlint and oxfmt clean on touched files. Typecheck shows no new errors.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
I used Claude (Opus 5.5) to trace the cause, build debug pages and write the change and tests. I reproduced the bug, directed the device testing and checked the fix on my own phone.
Review
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
Android only (hostOs() === 'android'); iOS and desktop untouched.
The 1 s and 50 ms values were tuned on one device. The keyboard close comes about 370 ms after the tap on a Galaxy S24+.
The refocus fires one extra blur and focus event on the field. That's harmless for the chat composer.
The keyboard briefly flickers before it comes back. Chromium hides it to show this menu (ChatGPT's site in Chrome does the same) and the page can't prevent that. Native fields like Discord's avoid it, but matching them would need native code and an app release.
The first key press after the menu only closes Chromium's menu. That's Chromium's popup behaviour, and Chrome does the same.
Not tested with Gboard.
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). Lint + mobile tests ran locally; full build left to CI.
…d word on Android
Chromium hides the soft keyboard to show the suggestion menu of a tapped
autocorrected word. The Android blur-on-keyboard-close hook treated that
like Back and blurred the composer, so the caret could never be placed
inside the word. When the hide follows a touch on the focused field within
1 s, keep focus and reopen the keyboard 50 ms later (blur, focus, restore
the selection). Back (no touch) still blurs.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
Walkthrough
On Android, keyboard closure now uses the timing and target of the latest pointerdown event to decide whether to dismiss the keyboard or refocus the active field after 50 ms. The refocus path restores the selection when both selection positions are available. New tests check retained focus and caret position after a recent field touch, and focus loss after an outside touch or a five-second delay. Additional tests cover a touch that focuses the field and a quick keyboard close after an outside touch when no field was focused.
Severity of issue fixed: Medium
Merge Risk: Low · up to 348d8
The Android behavior is likely mergeable, but the initial-focus test does not verify keyboard reopening and warrants follow-up.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta…
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 4 passed
Check name
Status
Explanation
Title check
The title states the main change: on Android, keep the cursor and keyboard when tapping an autocorrected word. The changeset adds pointer-touch tracking to keyboard-close-blur.web.ts that refocuses a …
Description check
The description follows the repository template closely. It has an ELI5 section, a What Changed section with before and after behavior and the mechanism, and a Why section that explains alternatives. …
Linked Issues check
Issue [#36747] requires the Android Samsung Keyboard autocorrect flow to preserve the chat cursor after the keyboard closes. keyboard-close-blur.web.ts tracks recent text-field touches, refocuses th…
Out of Scope Changes check
The pull request changes Android keyboard-close handling and its focused tests. Touch tracking, delayed refocus, selection restoration, and timer cleanup directly support [#36747] or preserve the exis…
Full details: Title check
Explanation
The title states the main change: on Android, keep the cursor and keyboard when tapping an autocorrected word. The changeset adds pointer-touch tracking to keyboard-close-blur.web.ts that refocuses a recently touched text field and restores its selection instead of dismissing the keyboard. The title matches this behavior and is scoped to mobile and Android. It is specific and within the length guidance.
Full details: Description check
Explanation
The description follows the repository template closely. It has an ELI5 section, a What Changed section with before and after behavior and the mechanism, and a Why section that explains alternatives. It links issue #36747 with a Fixes reference. It has Visual Proof (a before and after video link), a Testing section with device details and five new Vitest cases, an AI Disclosure, the agent skill upstream boundary checkbox, Notes, and a Checklist. Minor gaps: the final checklist item (pnpm build) is unchecked and the author notes the full build is left to CI. The Visual Proof section uses a video link and does not show the full before and after tabbing format, but it is present.
Full details: Linked Issues check
Explanation
Issue [#36747] requires the Android Samsung Keyboard autocorrect flow to preserve the chat cursor after the keyboard closes. keyboard-close-blur.web.ts tracks recent text-field touches, refocuses the field after a quick Android keyboard close, and restores the selection. The added tests cover caret preservation, delayed Back, outside touches, and touches that focus the field.
Full details: Out of Scope Changes check
Explanation
The pull request changes Android keyboard-close handling and its focused tests. Touch tracking, delayed refocus, selection restoration, and timer cleanup directly support [#36747] or preserve the existing Back behavior. No unrelated product changes are identified.
Full details: Docstring Coverage
Explanation
Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 3 functions across 2 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
The timer ordering and focus assertions cover the delayed refocus. The collapsed-selection assertion does not cover the explicit restoration in reopenKeyboard. Spy on setSelectionRange after the initial setup and assert the call after advancing the timer.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
…t refocus
document.activeElement is the body when nothing is focused, so any touch
passed body.contains(target), and a quick Back after tapping the terminal
reopened the keyboard. Ask whether the touch landed on an input or
textarea instead. A touch that focuses a field still counts, so tapping an
autocorrected word after Back keeps the caret. Also assert the selection
restore.
Assert that the touch-first-focus path starts a new focus session.
The current assertion passes from the initial TextInputState.focusTextInput(field) call even if the delayed refocus never runs. Add the listener after that initial focus so only the delayed field.focus() increments it.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
On Android, when Samsung Keyboard autocorrects a word and you tap it to fix it, the keyboard closes and Orca throws away the cursor. Now Orca keeps the cursor where you tapped and brings the keyboard straight back, so you can just backspace and retype that part of the word.
What Changed
keyboard-close-blur.web.ts):pointerdownand whether it landed on a text field (an input or textarea).Keyboard.dismiss()as before.Why
This is Orca-side, not a keyboard bug: plain Chrome on the same phone, with the same keyboard and the same tap, keeps the cursor. Orca loses it because of its own blur.
That blur from #32038 is still needed: after Back, a still-focused field lets the next terminal touch reopen the keyboard. But the hook treats every keyboard close as Back, and Chromium closes the keyboard itself to show the autocorrect menu. "Was the field just touched?" tells them apart (Back has no touch).
Alternatives tried or considered:
spellcheck=falseon the field. Tested: the underline and menu still appear.Why a 1 s time window and not something cleaner:
Each alternative was tried first in a plain Chrome test page on the same phone; only the refocus brought the keyboard back with the cursor in place.
Linked Issue
Fixes #36747
Visual Proof
Before (left, 1.4.245) vs After (right, this PR). Same phone, same steps, in sync.
CARETFIX_V3_nlx_BEFORE_AFTER_2026-10-31.mp4
Testing
Real device: Galaxy S24+ (Android 16, Samsung Keyboard), Android app 0.0.61 against desktop 1.4.245 on Windows, with this change built into the mobile page.
Vitest
keyboard-close-blur.web.test.ts, 5 new cases:7/7 pass.
src/platform+web-entrysuites: 226 pass.oxlint and oxfmt clean on touched files. Typecheck shows no new errors.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
I used Claude (Opus 5.5) to trace the cause, build debug pages and write the change and tests. I reproduced the bug, directed the device testing and checked the fix on my own phone.
Review
Agent skill upstream boundary
Notes
Android only (
hostOs() === 'android'); iOS and desktop untouched.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred). Lint + mobile tests ran locally; full build left to CI.