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

未关闭 适合新手
#8,318 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

@IsaacIsrael 已经在做这个了。

开始于 2026年6月1日。

  • #8319 来自 @IsaacIsrael —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
78/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
冷清
技术栈
ios, objective-c, react-native
领域
mobile

调研方向

从 UIViewController+RNNOptions.mm 中的 setSearchBarWithOptions: 开始,对比已有 controller 路径与初始创建路径。在具有已有 search controller 的页面上验证 mergeOptions 流程,然后运行相关的 iOS 测试或复现切换标签页的步骤。完成标准是:focus: true 会在 mergeOptions 后让 search bar 重新获得焦点,同时不改变初始创建行为。

由索引模型根据 Issue 内容生成。

描述

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+
主要语言
MDX
星标
13.2k
派生
2.6k
平均合并
2 天 10 小时
30 天内合并 PR
6

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

wix/react-native-navigation 的其他 Issue

查看 wix/react-native-navigation 的全部 Issue

相似的 Issue

更多 Mobile Dev Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。