[iOS][Fabric] TextInput drops a keystroke right after the first character typed into an empty field (_textOf:equals: compares attributes of a focused field)
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 78/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- ios, objective-c, react-native
- Bereich
- mobile
Rechercherichtung
Lies RCTTextInputComponentView.mm, insbesondere _textOf:equals: und die vorhandenen Prüfungen für Diktat, markierten Text und sichere Eingabe. Reproduziere den Fall mit schnellem Tippen mithilfe des verlinkten Reproducers und vergleiche sein Verhalten vor und nach der vorgeschlagenen Gleichheitsprüfung für den First Responder. Das Ziel ist erreicht, wenn dieselben Zeichen in einem fokussierten Feld nicht mehr das Update auslösen, durch das ein Tastendruck verloren geht, und der Reproducer bestätigt, dass das Problem behoben ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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:
- The first character typed into an empty field reaches the native view with UIKit's typing attributes.
- The state round trip brings the same character back as an attributed string with React Native's full attribute set.
-[RCTTextInputComponentView _textOf:equals:]compares the two strings including their attributes. It answers NO, although the characters are identical.- 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
- Render an uncontrolled
TextInput(defaultValueonly,keyboardType="number-pad"). Leave it empty, and give it a style that setsfontSize,lineHeightandcolor. - Focus it and type two digits quickly as one burst, for example «2» then «8» within about 100 ms.
- 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 |
|---|---|
![]() |
![]() |
- Vorherrschende Sprache
- C++
- Sterne
- 127k
- Forks
- 25.3k
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus react/react-native
-
Needs: Author Feedback Needs: Repro
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
react/react-native#58659 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Needs: Author Feedback Needs: Repro
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 92/100
react/react-native#58621 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Add TypeScript declaration for the performance globalEvtl. vergeben @Cedric921 hat das vor 3 Tagen übernommen. OffenNeeds: Attention Needs: Repro
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
react/react-native#58610 · 4 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Needs: Triage :mag:
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
react/react-native#58565 · 2 Kommentare · 2 Reaktionen ·
Maintainer antworten meist innerhalb von 1 Tag
-
[Android][Fabric] addViewAt hard-crashes on a placeholder ViewState synthesised by updateEventEmitterEvtl. vergeben @wneel hat das vor 23 Tagen übernommen. OffenNeeds: Attention Needs: Repro
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
react/react-native#58526 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in react/react-native
Ähnliche Issues
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
EsotericSoftware/spine-runtimes#3186 ·
-
An empty line splits a signature where an ordinary comment is right above an argument's HaddockOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
mrkkrp/tilia#213 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Round video messages start gray and blocky with libx264: encoder is configured for 1,000,000 fpsOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
telegramdesktop/tdesktop#31422 ·
Maintainer antworten meist innerhalb von 9 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
Maintainer antworten meist innerhalb von 5 Tagen

