fix(iOS): prevent search bar from reopening keyboard on header button press#3676
Open
just1and0 wants to merge 1 commit intosoftware-mansion:mainfrom
Open
fix(iOS): prevent search bar from reopening keyboard on header button press#3676just1and0 wants to merge 1 commit intosoftware-mansion:mainfrom
just1and0 wants to merge 1 commit intosoftware-mansion:mainfrom
Conversation
… press When a screen has both a search bar and header buttons, tapping a header button after dismissing the search bar keyboard causes the keyboard to reopen unexpectedly. This happens because: 1. updateViewController unconditionally reassigns navitem.searchController on every render cycle, causing UIKit to re-activate the search bar. 2. searchBarCancelButtonClicked does not resign first responder on the actual UISearchBar, only on the RNSSearchBar wrapper. This commit guards the searchController assignment to only occur when the value changes, and ensures the native search bar properly resigns first responder when cancelled.
This was referenced Feb 22, 2026
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.
Description
Closes #3677.
When a screen has both a
headerSearchBarOptionssearch bar and header buttons (e.g.headerRight), tapping a header button after dismissing the search bar keyboard causes the keyboard to reopen unexpectedly.Repro steps:
Minimal reproduction: https://github.com/sbkl/sdk-55-header-right-button-opening-keyboard
Also reported on Expo: expo/expo#43198
Changes
Two fixes in the iOS native code:
RNSScreenStackHeaderConfig.mm: Guard thenavitem.searchControllerassignment to only occur when the value actually changes. Previously, this was unconditionally reassigned on everyupdateViewControllercall, which caused UIKit to re-activate the search bar and trigger the keyboard.RNSSearchBar.mm: InsearchBarCancelButtonClicked:, also callresignFirstResponderon the actual_controller.searchBar(the nativeUISearchBar), not just onself(theRNSSearchBarwrapper). This ensures the search bar fully gives up keyboard focus when cancelled.Before & after
Before (bug)
Screen.Recording.2026-02-17.at.9.09.11.AM.mov
After focusing and dismissing the search bar, tapping the header menu button reopens the keyboard.
After (fix)
After the fix, tapping the header menu button correctly triggers the menu action without reopening the keyboard.
Test plan
TestSearchBarKeyboardReopen.tsxinapps/src/tests/issue-tests/Checklist