react / react/react-native

iOS only: `onChangeText` of `TextInput` is fired with text longer than `maxLength`

Đang mở
#41,893 2 bình luận 2 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Component: TextInput Issue: Author Provided Repro Platform: iOS Resolution: PR Submitted
Ngôn ngữ chính
C++
Star
127k
Fork
25.3k
Merge trung bình
1 ngày 23 giờ
Pull request đã merge (30 ngày)
4

Mô tả

Description

We noticed that sometimes the onChangeText event of TextInput was fired with text longer than maxLength. According to the doc, this behaviour seems to be unexpected.

maxLength:
Limits the maximum number of characters that can be entered.

This happens only on iOS relating to autocompletion.

Steps to reproduce

Here is a snack link to reproduce the issue: https://snack.expo.dev/@yupeng_li/textinput

It contains only a TextInput component and maxLength is set to 3. If you type in bef and let the autocomplete suggestion come up, you will see an alert triggered by onChangeText when text is longer the maxLength.

In the screenshot below, the text returned is "Before", and the text displayed in the input is "ore".

image

React Native Version

0.71.14

Affected Platforms

Runtime - iOS

Output of npx react-native info
info Fetching system and libraries information...
System:
    OS: macOS 14.1.2
    CPU: (10) arm64 Apple M1 Pro
    Memory: 81.80 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.17.0 - ~/Library/Caches/fnm_multishells/24849_1670237417415/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.6.7 - ~/Library/Caches/fnm_multishells/24849_1670237417415/bin/npm
    Watchman: 2023.10.09.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: Not Found
  SDKs:
    iOS SDK:
      Platforms: DriverKit 23.0, iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0
    Android SDK: Not Found
  IDEs:
    Android Studio: 2022.3 AI-223.8836.35.2231.10671973
    Xcode: 15.0.1/15A507 - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.19 - /Users/yupeng/.sdkman/candidates/java/11.0.19-tem/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.2.0 => 18.2.0
    react-native: 0.71.14 => 0.71.14
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found
info React Native v0.73.0 is now available (your project is running on v0.71.14).
info Changelog: https://github.com/facebook/react-native/releases/tag/v0.73.0
info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.71.14
info For more info, check out "https://reactnative.dev/docs/upgrading".
Stacktrace or Logs
No stacktrace
Reproducer

https://snack.expo.dev/@yupeng_li/textinput

Screenshots and Videos

No response

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với reproducer Snack được liên kết và hành vi của TextInput onChangeText/maxLength trên iOS, đặc biệt khi autocomplete chèn văn bản. Theo dõi entry point của iOS TextInput để xác định lý do callback nhận được "Before" trong khi trường hiển thị "ore". Hoàn tất khi autocomplete không thể khiến onChangeText báo cáo văn bản dài hơn maxLength và hành vi của reproducer đã được sửa.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
ios, react-native
Lĩnh vực
mobile
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.