Bug
When calling Navigation.mergeOptions() with topBar.searchBar.focus: true on a screen that already has a search controller, the focus is silently ignored. The search bar only auto-focuses on initial creation (first applyOptions), never on subsequent mergeOptions calls.
Current Behaviour
setSearchBarWithOptions: in UIViewController+RNNOptions.mm only handles focus inside the if (!self.navigationItem.searchController) branch (initial creation). The else branch (existing search controller) skips focus entirely.
Expected Behaviour
mergeOptions with focus: true should refocus the search bar even when the search controller already exists. This is needed for re-focusing the search bar when the screen reappears (e.g., switching back to a bottom tab).
Steps to Reproduce
- Register a screen with
searchBar: { visible: true, focus: true } in static options
- Screen mounts — search bar is focused (correct)
- Navigate away from the screen (e.g., switch tabs)
- Navigate back and call
Navigation.mergeOptions(componentId, { topBar: { searchBar: { visible: true, focus: true } } })
- Search bar is not focused
Proposed Fix
Add focus handling in the else branch of setSearchBarWithOptions::
} else {
// ... existing iOS 26 placement code ...
if (focus) {
dispatch_async(dispatch_get_main_queue(), ^{
self.navigationItem.searchController.active = true;
[self.navigationItem.searchController.searchBar becomeFirstResponder];
});
}
}
Environment
- react-native-navigation: 8.8.2
- React Native: 0.85.3
- iOS 18+
Bug
When calling
Navigation.mergeOptions()withtopBar.searchBar.focus: trueon a screen that already has a search controller, the focus is silently ignored. The search bar only auto-focuses on initial creation (firstapplyOptions), never on subsequentmergeOptionscalls.Current Behaviour
setSearchBarWithOptions:inUIViewController+RNNOptions.mmonly handlesfocusinside theif (!self.navigationItem.searchController)branch (initial creation). Theelsebranch (existing search controller) skips focus entirely.Expected Behaviour
mergeOptionswithfocus: trueshould refocus the search bar even when the search controller already exists. This is needed for re-focusing the search bar when the screen reappears (e.g., switching back to a bottom tab).Steps to Reproduce
searchBar: { visible: true, focus: true }in static optionsNavigation.mergeOptions(componentId, { topBar: { searchBar: { visible: true, focus: true } } })Proposed Fix
Add focus handling in the
elsebranch ofsetSearchBarWithOptions::Environment