镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

[iOS][Fabric] TextInput drops a keystroke right after the first character typed into an empty field (_textOf:equals: compares attributes of a focused field) #58904

Description

@vdzerkalo

Description

On iOS with the New Architecture (Fabric), typing quickly into an empty TextInput sometimes loses the second key. For example, typing «28» into an empty numeric field leaves «2». It happens only for the first character typed into an empty field, and only in a fast burst. Fields that already contain text are not affected.

We traced it as follows:

  1. The first character typed into an empty field reaches the native view with UIKit's typing attributes.
  2. The state round trip brings the same character back as an attributed string with React Native's full attribute set.
  3. -[RCTTextInputComponentView _textOf:equals:] compares the two strings including their attributes. It answers NO, although the characters are identical.
  4. React Native then calls setAttributedText: on the field while it is the first responder. That resets UIKit's keyboard / input pipeline, and the key in flight at that moment is dropped.

_textOf:equals: already has exceptions for dictation, Korean input, marked text and secure entry. One more exception fixes it in our app: while the backed text input view is the first responder, two strings with equal characters are treated as equal.

Suggested fix, in RCTTextInputComponentView.mm, _textOf:equals:: when _backedTextInputView is the first responder, compare only newText.string with oldText.string, next to the existing dictation / marked text / secure entry checks. Then a state round trip of the same characters never calls setAttributedText: on a focused field.

Workaround: we swizzle _textOf:equals: with that exception in a small native module, and will remove it once a release includes a fix.

Steps to reproduce

  1. Render an uncontrolled TextInput (defaultValue only, keyboardType="number-pad"). Leave it empty, and give it a style that sets fontSize, lineHeight and color.
  2. Focus it and type two digits quickly as one burst, for example «2» then «8» within about 100 ms.
  3. Repeat, emptying the field between runs.

Expected: «28». Actual: «2» in some of the bursts.

Our measurements (iOS 27 simulator, Release build):

  • without the exception, 5 of 13 two- and three-digit bursts lost a key;
  • with the exception, 0 of 12 did.

React Native Version

0.86.3

Affected Platforms

Runtime - iOS

Areas

Fabric - The New Renderer

Output of npx @react-native-community/cli info

System:
  OS: macOS 27
  CPU: Apple Silicon
Binaries:
  Node: 25.9.0
  Bun: 1.3.11
IDEs:
  Xcode: 27.0 (27A266a)
npmPackages:
  react: 19.2
  react-native: 0.86.3
  expo: 57
iOS:
  hermesEnabled: true
  newArchEnabled: true

Stacktrace or Logs

No crash or log: a key is silently lost. In the debugger, `-[RCTTextInputComponentView _textOf:equals:]` returns NO for an
equal one-character string (UIKit typing attributes vs React Native's attribute set), and `setAttributedText:` runs on the
first responder right before the lost key.

MANDATORY Reproducer

https://github.com/vdzerkalo/rn-58904-textinput-lost-key

Made from the reproducer template: react-native 0.87.1 (latest), New Architecture, no extra dependencies. Six empty, uncontrolled fields; each row compares the keys onKeyPress reported with the characters that landed in the field. iOS 27 simulator, Release: 9 of 18 bursts of «28» lost the second key; with the suggested change applied at runtime (-ApplySuggestedFix YES, off by default), 0 of 18.

Screenshots and Videos

One Release round each from the reproducer (iOS 27 simulator, a fresh launch, six bursts of «28»). Left: React Native 0.87.1 as is, 5 of 6 bursts lost the second key. Right: with the suggested change (-ApplySuggestedFix YES), 0 of 6.

As is With the suggested change
5 of 6 bursts of 28 ended as 2 0 of 6 bursts lost a key

Activity

  1. react-native-bot commented on Oct 7, 2026

    @react-native-bot
    Collaborator

    Warning

    Missing reproducer: We could not detect a reproducible example in your issue report. Reproducers are mandatory and we can accept only one of those as a valid reproducer:


    You can read more about about it on our website: How to report a bug.

  2. added a commit that references this issue on Oct 7, 2026
  3. vdzerkalo commented on Oct 7, 2026

    @vdzerkalo
    Author

    Reproducer: https://github.com/vdzerkalo/rn-58904-textinput-lost-key (now also in the issue body).

    • Made from the reproducer template: react-native 0.87.1 (latest), New Architecture, no extra dependencies. RCTTextInputComponentView.mm is the same as in 0.86.3 apart from one comment.
    • App.tsx: six empty, uncontrolled TextInputs (defaultValue="", keyboardType="number-pad", a style with fontSize, lineHeight and color). Each row compares the keys onKeyPress reported with the characters that landed in the field: a lost key fires onKeyPress but never reaches the field.
    • Steps: yarn ios --mode Release, simulator hardware keyboard on, tap a field, type 2 8 quickly as one burst, then the next field.

    Results (iPhone 17 Pro simulator, iOS 27.0, Xcode 27.0; a round = a fresh launch and six bursts of 28; JS received the second key 0-33 ms after the first):

    Build Bursts Lost a key
    Release, 0.87.1 as is 18 9
    Release, the suggested _textOf:equals: change applied at runtime (-ApplySuggestedFix YES) 18 0
    Debug, 0.87.1 as is 12 2

    The switch is in AppDelegate.swift and is off by default, so the A/B needs no React Native source build. Not related to this bug: the template does not launch on iOS 27 when built with Xcode 27 (no UIScene life cycle), so the repo also adds a minimal SceneDelegate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: AttentionIssues where the author has responded to feedback.Needs: ReproThis issue could be improved with a clear list of steps to reproduce the issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions