描述
在iOS中添加textContentType并设置maxLength=10时,点击建议的结果是不相关的。
重现步骤
在TextInput中尝试添加以下属性;
textContentType={'telephoneNumber'},
maxLength={10}
这将给您显示手机号码建议,手机号码有时会有国家代码和空格,当用户点击手机号码时,自动填充结果不合适。
例如:
如果手机号码是88844 33322,共有11个字符,最后一个数字会被截断
建议:88844 33322
结果:88844 3332
所以我们需要一个机制在填充文本输入之前去除空格/国家代码。目前onChangeText使用截断后的结果调用,因此在设置maxLength时无法在调用onChangeText之前进行格式化。
React Native版本
0.73.1
受影响的平台
运行时 - iOS
npx react-native info
的输出
System:
OS: macOS 14.4.1
CPU: (8) arm64 Apple M1
Memory: 68.98 MB / 16.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 18.16.1
path: ~/.nvm/versions/node/v18.16.1/bin/node
Yarn:
version: 1.22.22
path: ~/.nvm/versions/node/v18.16.1/bin/yarn
npm:
version: 9.5.1
path: ~/.nvm/versions/node/v18.16.1/bin/npm
Watchman:
version: 2023.12.04.00
path: /usr/local/bin/watchman
Managers:
CocoaPods:
version: 1.15.2
path: /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 23.4
- iOS 17.4
- macOS 14.4
- tvOS 17.4
- visionOS 1.1
- watchOS 10.4
Android SDK:
API Levels:
- "17"
- "23"
- "27"
- "28"
- "29"
- "30"
- "31"
- "33"
- "34"
Build Tools:
- 29.0.2
- 30.0.0
- 30.0.1
- 30.0.2
- 30.0.3
- 31.0.0
- 33.0.0
- 33.0.1
- 34.0.0
System Images:
- android-26 | Google APIs ARM 64 v8a
- android-28 | Google ARM64-V8a Play ARM 64 v8a
- android-29 | Google Play ARM 64 v8a
- android-30 | Google APIs ARM 64 v8a
- android-31 | Google APIs ARM 64 v8a
- android-32 | Google Play ARM 64 v8a
- android-34 | Google APIs ARM 64 v8a
Android NDK: Not Found
IDEs:
Android Studio: 2023.2 AI-232.10300.40.2321.11668458
Xcode:
version: 15.3/15E204a
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.6
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.73.1
wanted: 0.73.1
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: false
iOS:
hermesEnabled: true
newArchEnabled: false
堆栈跟踪或日志
N/A
可复现步骤
Snack ( https://snack.expo.dev/coZ_oQ_slq87v8yIMImV4 )
截图和视频
- 无响应*
3条答案
按热度按时间x6492ojm1#
imzjd6km2#
这个问题已经等待作者24天反馈。请提供所需的反馈,否则将在7天后关闭。
4ioopgfo3#
零食以复制:https://snack.expo.dev/coZ_oQ_slq87v8yIMImV4