TextInput abnormal behaviour of setNativeProps for updating selection
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 30/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- javascript, react-native
- 领域
- mobile-dev
调研方向
从必需的 Snack 复现用例开始,并在 New architecture 下比较 Android 和 iOS 上 TextInput 使用 setNativeProps 时的选择行为。跟踪从 setNativeProps 开始的 TextInput 选择更新路径;当光标位置和文本选择在两个平台上都与预期位置一致时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Description
This repository reproduces a bug in React Native where calling setNativeProps with the selection property on a TextInput component fails to update the cursor position or text selection as expected. The issue started happening after migrating to New architecture. Legacy architecture handles same logic without issues.
When attempting to programmatically control text selection in a TextInput using setNativeProps({ selection: { start, end } }), the following issues occur:
- The cursor position does not update on Android
- The cursor jump abnormally on iOS
- Selection changes are ignored or behave inconsistently
- iOS and Android exhibit different behaviors
Steps to reproduce
- Open the snack link
- Tap on first button to set initial text
First line of text should be selected, but it does not work on Android
- Reposition the cursor to centre of text by tapping
- Press second button to add img link -
iOS side bug will appear on this step, cursor jumps to wrong position
- Press third button to select all
Both android and iOS will fail
- Tap on fourth button insert md bold block
On both android and ios, cursor gets placed on either start or end, instead of being placed at
**|**
React Native Version
0.79.5
Affected Platforms
Runtime - iOS, Runtime - Android
Areas
JSI - Javascript Interface
Output of npx @react-native-community/cli info
System:
OS: macOS 15.2
CPU: (10) arm64 Apple M4
Memory: 141.75 MB / 24.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 24.5.0
path: /opt/homebrew/opt/node@21/bin/node
Yarn:
version: 1.22.22
path: ~/Documents/ReactNativeProjects/ecency-mobile/node_modules/.bin/yarn
npm:
version: 11.5.1
path: /opt/homebrew/opt/node@21/bin/npm
Watchman:
version: 2025.03.10.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.16.2
path: /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 24.4
- iOS 18.4
- macOS 15.4
- tvOS 18.4
- visionOS 2.4
- watchOS 11.4
Android SDK:
API Levels:
- "28"
- "30"
- "31"
- "33"
- "34"
- "35"
Build Tools:
- 28.0.3
- 29.0.2
- 29.0.3
- 30.0.2
- 30.0.3
- 31.0.0
- 33.0.0
- 33.0.1
- 33.0.2
- 34.0.0
- 35.0.0
- 35.0.0
- 35.0.0
System Images:
- android-29 | Google Play ARM 64 v8a
- android-30 | Google Play ARM 64 v8a
- android-31 | Google APIs ARM 64 v8a
- android-31 | Google Play ARM 64 v8a
- android-32 | Google APIs ARM 64 v8a
- android-32 | Google Play ARM 64 v8a
- android-33 | Google APIs ARM 64 v8a
- android-33 | Google Play ARM 64 v8a
- android-34 | Google APIs ARM 64 v8a
- android-34 | Google Play ARM 64 v8a
- android-35 | Google Play ARM 64 v8a
- android-36.1 | Google Play ARM 64 v8a
- android-36 | Google Play ARM 64 v8a
- android-Baklava | Pre-Release 16 KB Page Size Google Play ARM 64 v8a
Android NDK: Not Found
IDEs:
Android Studio: 2025.1 AI-251.25410.109.2511.13752376
Xcode:
version: 16.3/16E140
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.5
path: /usr/bin/javac
Ruby:
version: 3.4.2
path: /opt/homebrew/opt/ruby/bin/ruby
npmPackages:
"@react-native-community/cli":
installed: 18.0.0
wanted: 18.0.0
react:
installed: 19.0.0
wanted: 19.0.0
react-native:
installed: 0.79.5
wanted: 0.79.5
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: Not found
newArchEnabled: Not found
iOS:
hermesEnabled: Not found
newArchEnabled: true
Stacktrace or Logs
Not applicable
MANDATORY Reproducer
https://snack.expo.dev/@noumantahir/textinput-setnativeprops-selection-bug
Screenshots and Videos
Android Response
https://github.com/user-attachments/assets/55dfa9b3-3a8a-4708-a193-c2cfaab5c2e1
iOS Response
https://github.com/user-attachments/assets/2dd095ed-60a1-4ecf-a31a-534df6d90983
- 主要语言
- C++
- 星标
- 127k
- 派生
- 25.3k
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
react/react-native 的其他 Issue
-
Needs: Author Feedback Needs: Repro
难度 1/5 1 小时以内 新手友好度 92/100
react/react-native#58621 · 1 条评论 ·
-
Needs: Author Feedback Needs: Repro
难度 2/5 1-3 小时 新手友好度 85/100
react/react-native#58610 · 1 条评论 ·
-
Needs: Triage :mag:
难度 2/5 1-3 小时 新手友好度 82/100
react/react-native#58565 · 1 条评论 · 2 个 reaction ·
-
Needs: Author Feedback Needs: Repro
难度 2/5 1-3 小时 新手友好度 88/100
react/react-native#58555 · 5 条评论 · 2 个 reaction ·
-
Needs: Attention Needs: Repro
难度 2/5 1-3 小时 新手友好度 85/100
react/react-native#58526 · 2 条评论 ·
查看 react/react-native 的全部 Issue
相似的 Issue
-
ai_reviewed
难度 2/5 1-3 小时 新手友好度 68/100
ydb-platform/ydb#53869 · 3 条评论 ·
-
bug cert blocker needs triage
难度 2/5 1-3 小时 新手友好度 82/100
project-chip/connectedhomeip#74373 ·
-
upstream update
难度 2/5 1-3 小时 新手友好度 75/100
conan-io/conan-center-index#31035 ·
-
Bug
难度 2/5 1-3 小时 新手友好度 68/100
-
documentation
难度 1/5 1 小时以内 新手友好度 85/100
vllm-project/vllm-ascend#17329 ·