[Fix] searchBar `focus:` true ignored on mergeOptions when searchController already exists
评估
- 难度
- 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
- 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+
- 主要语言
- MDX
- 星标
- 13.2k
- 派生
- 2.6k
- 平均合并
- 2 天 10 小时
- 30 天内合并 PR
- 6
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
wix/react-native-navigation 的其他 Issue
-
needs triage triage: documentation
难度 2/5 1-3 小时 新手友好度 68/100
wix/react-native-navigation#8343 · 1 条评论 ·
-
needs triage type: accepted/bug
难度 4/5 3-5 天 新手友好度 25/100
wix/react-native-navigation#8365 · 2 条评论 ·
-
`showOverlay` creates a scene-less `UIWindow`, so overlays never appear under UIScene lifecycle可能已有人在做 @yedidyak 于 3 天前认领。 未关闭platform: iOS type: accepted/bug
难度 3/5 1-2 天 新手友好度 68/100
wix/react-native-navigation#8345 · 2 条评论 · 2 个 reaction ·
-
platform: iOS type: accepted/bug
难度 4/5 3-5 天 新手友好度 48/100
wix/react-native-navigation#8340 ·
-
platform: iOS type: accepted/bug
难度 4/5 3-5 天 新手友好度 48/100
wix/react-native-navigation#8339 ·
查看 wix/react-native-navigation 的全部 Issue
相似的 Issue
-
feat: 앱 정보에 개인정보처리방침과 고객지원 연결可能已有人在做 @xrpjwk8 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 62/100
DeveloperAcademy-POSTECH/2026-C6-A13-Hear-I-am#120 ·
维护者通常 1 天内回复
-
Bug
难度 1/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
e2e-failure
难度 2/5 1-3 小时 新手友好度 78/100
home-assistant/android#7809 ·
维护者通常 1 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 3 天内回复