The TextInput's showSoftInputOnFocus prop is causing unnecessary events to be triggered.
还没有人认领这个 Issue。
- 主要语言
- C++
- 星标
- 127k
- 派生
- 25.3k
- 平均合并
- 1 天 23 小时
- 30 天内合并 PR
- 4
描述
Description
I'm encountering an issue with the TextInput component in React Native when using the showSoftInputOnFocus prop. When the TextInput gains focus, the keyboard does not open, the keyboardWillShow and keyboardDidShow events are not triggered. However, upon losing focus, the keyboardWillHide and keyboardDidHide events are fired.
This behavior causes problems with Keyboard Aware components that listen for these events.
Steps to reproduce
- Create a new React Native project.
- Add a
TextInputcomponent with theshowSoftInputOnFocusprop set to false. - Add event listeners for
keyboardWillShow,keyboardDidShow,keyboardWillHide, andkeyboardDidHideevents. - Focus on the
TextInputand observe thatkeyboardWillShowandkeyboardDidShowevents are not triggered. - Blur the TextInput and observe that
keyboardWillHideandkeyboardDidHideevents are triggered.
React Native Version
0.72.9
Affected Platforms
Runtime - iOS
Output of npx react-native info
System:
OS: macOS 14.2.1
CPU: (8) arm64 Apple M1 Pro
Memory: 140.09 MB / 16.00 GB
Shell:
version: 3.2.57
path: /bin/bash
Binaries:
Node:
version: 18.18.2
path: ~/miniconda3/bin/node
Yarn:
version: 1.22.19
path: /usr/local/bin/yarn
npm:
version: 9.8.1
path: ~/miniconda3/bin/npm
Watchman: Not Found
Managers:
CocoaPods:
version: 1.13.0
path: /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 23.0
- iOS 17.0
- macOS 14.0
- tvOS 17.0
- watchOS 10.0
Android SDK:
API Levels:
- "32"
- "33"
- "33"
Build Tools:
- 30.0.3
- 33.0.0
- 33.0.2
System Images:
- android-33 | Google APIs ARM 64 v8a
- android-33 | Google APIs Intel x86_64 Atom
- android-33 | Google Play ARM 64 v8a
Android NDK: Not Found
IDEs:
Android Studio: 2022.1 AI-221.6008.13.2211.9619390
Xcode:
version: 15.0/15A240d
path: /usr/bin/xcodebuild
Languages:
Java:
version: 18.0.2.1
path: /usr/bin/javac
Ruby:
version: 2.6.10
path: /usr/bin/ruby
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 18.2.0
wanted: 18.2.0
react-native:
installed: 0.72.9
wanted: 0.72.9
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: Not found
newArchEnabled: Not found
iOS:
hermesEnabled: Not found
newArchEnabled: Not found
Stacktrace or Logs
There is no crash.
Reproducer
https://snack.expo.dev/@kubatyi.dev/692c3c
Screenshots and Videos
No response
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从链接的 Snack 复现示例和在 iOS 上使用 showSoftInputOnFocus 的 React Native TextInput 入口点开始;跟踪 focus 和 blur 期间 keyboardWillShow、keyboardDidShow、keyboardWillHide 和 keyboardDidHide 的行为。完成的标准是:键盘未显示时,报告的配置不再触发 hide 事件,并且该场景已通过回归检查验证。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- ios, react-native
- 领域
- mobile
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 38/100