Fix keyboard reappearing on search-only back#8945
Merged
Merged
Conversation
When the native input is dismissed via the back arrow in SEARCH_ONLY mode, the keyboard would hide and then immediately reappear. In that mode the input field still holds focus when Back is pressed, so a focused, still-attached EditText remains the IME target and the window re-requests the keyboard right after the hide. SEARCH_AND_DUCK_AI was unaffected because the field had already lost focus by then. Clear the input field's focus before hiding the IME in the back handler so there is no editor for the window to re-show the keyboard for. This is a no-op in SEARCH_AND_DUCK_AI where focus is already gone. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Task/Issue URL: https://app.asana.com/1/137249556945/project/1204912272578138/task/1215751565522437?focus=true
Tech Design URL (if applicable):
Description
With native input enabled and the Search Only address-bar option selected, focusing the input field and pressing the top-left back arrow hid the keyboard but it immediately popped back up. Search & Duck.ai worked as expected.
Root cause: the native input
onBackhandler calledhideKeyboard()but never cleared focus. InSEARCH_ONLYmode the input field still holds focus when Back is pressed, so a focused, still-attachedEditTextremains the IME target and the window re-requests the keyboard right after the hide. InSEARCH_AND_DUCK_AIthe field had already lost focus, so the hide stuck — which is why only Search Only was affected.Fix: clear the input field's focus before hiding the IME in the back handler, so there's no editor for the window to re-show the keyboard for. It's a no-op in
SEARCH_AND_DUCK_AIwhere focus is already gone.Confirmed on-device with temporary instrumentation (since removed). In Search Only, the dismiss trace went from
hideKeyboard: focus=true/onHide: focus=inputField(keyboard returns) tohideKeyboard: focus=false/onHide: focus=null(keyboard stays down), matching the working Search & Duck.ai trace.Steps to test this PR
Search Only (the fix)
Search & Duck.ai (regression)
UI changes
No visual changes — keyboard dismissal behavior only. Verified on emulator (API 37) in both address-bar modes.
Note
Low Risk
Single-line behavioral change in the back handler using an existing widget API; no auth, data, or broad refactors.
Overview
Fixes the keyboard popping back up after tapping the native input’s top-left back control when Search Only is selected.
The
onBackhandler inNativeInputManagernow callsclearInputFocus()beforehideKeyboard()and closing the widget. In Search Only the field still had focus on Back, so the window kept treating theEditTextas the IME target and re-requested the keyboard right after hide. Dropping focus first removes that target so dismissal sticks. Search & Duck.ai was unaffected (focus was already gone);clearInputFocus()is a no-op there.Reviewed by Cursor Bugbot for commit 9bcac4c. Bugbot is set up for automated code reviews on this repo. Configure here.