wix / wix/react-native-navigation

[Fix] searchBar `focus:` true ignored on mergeOptions when searchController already exists

Open Beginner friendly
#8,318 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
MDX
Stars
13.2k
Forks
2.6k
Avg merge
6d 2h
Merged PRs (30d)
1

Description

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
  1. Register a screen with searchBar: { visible: true, focus: true } in static options
  2. Screen mounts — search bar is focused (correct)
  3. Navigate away from the screen (e.g., switch tabs)
  4. Navigate back and call Navigation.mergeOptions(componentId, { topBar: { searchBar: { visible: true, focus: true } } })
  5. 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+

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in UIViewController+RNNOptions.mm at setSearchBarWithOptions:, comparing the existing-controller path with the initial creation path. Verify the mergeOptions flow on a screen with an existing search controller, then run the relevant iOS tests or reproduce the tab-switching steps. Done means focus: true refocuses the search bar after mergeOptions without changing initial creation behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, objective-c, react-native
Domain
mobile
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.