fix: drop a controlled selection rendered before the latest edits - #58
Merged
Merged
Conversation
A selection prop rendered before JS saw the latest native edits was still applied, while the text prop in the same render was already held back by the mostRecentEventCount handshake. Typed faster than JS renders, a caret computed for '1' landed in a field showing '1234' and the next digits went in behind the first: Uno's code field took '123456' as '156234' on a Galaxy A22. The selection now uses the same guard, as React Native's TextInput does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
In Uno's manual testing on the Galaxy A22, the code field typed
123456as156234, and12345as14253, whenever the digits came faster than JS could render.The code field is Uno's
SegmentedInput: a hidden NitroInput with a controlledvalueand a controlledselectionthat keeps the caret where the boxes say it is.The text handshake (
mostRecentEventCount) already holds back avaluerendered before JS saw the latest edits, but theselectionin that same render was still applied. So a caret computed for "1" landed in a field that already held "1234", and the next digits went in behind the first.What
A controlled
selectionis now dropped under the same condition astext: JS's count is behind the native edit count. React Native'sTextInputdoes the same (maybeSetSelectionchecks the event count).selectionrendered after JS has caught up still applies.setSelection()is unaffected.Android (
flushSelectionIfNeeded) and iOS (applySelectionIfNeeded), with a CHANGELOG entry under## 0.3.6.Tests
adb shell input text:12345→14253,123456→156234;12345four times out of four, and123456.bun run test: 171/171.bun run typecheckbun run test:harness:ios: 120/120.:react-native-nitro-input:assembleDebug).🤖 Generated with Claude Code