feat: focusedValue, and worklet focus handlers that see autoFocus - #57
Merged
Merged
Conversation
- `focusedValue`: a shared value the field keeps equal to its focus on the UI thread, alongside JS onFocus/onBlur. Lets an app draw a focus border around a row with icons or buttons beside the field in the frame focus lands, with no JS round trip. - Focus worklets are registered while rendering instead of in an effect, so an autoFocus field's first focus (taken as its view attaches) reaches them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…pped React unmounts a popped screen's focused field before react-native-screens starts the pop, so its keyboardHandoffMs hold could not tell a pop from a field swapped in place and kept the keyboard up over the screen popped back to for the whole hold. A hold now watches the leaving field's screen and ends as soon as that screen starts to leave, unless a field is waiting to take the keyboard (a covered field taking it back, a focus() held for its view). 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
Uno wants every input to show a blue border the moment it's focused, around the whole field row: a leading icon or country picker, the field itself and a trailing clear button. NitroInput's own frame (
variant) only wraps the NitroInput view, and native views can't hold children. The other option, JSonFocusplussetState, costs a JS round trip before the border shows.A glitch sweep in Uno also turned up an iOS keyboard bug, fixed in the same release (see the last item under What).
What
focusedValueprop: pass a shared value (useSharedValue(false)). The field sets it on the UI thread the moment focus changes, andonFocus/onBlurkeep running on JS. The app then draws the border on its own row from the shared value, in the same frame the caret appears.autoFocusfield's first focus could arrive before registration and be dropped. This also fixes workletonFocusanduseNitroInputState().focusedforautoFocusfields.keyboardHandoffMs, to a screen where no field takes the keyboard (Uno's account list after the amount screen), the keyboard stayed up over that screen for the whole hold.focus()held for its view).Tests
bun run test: 171/171. The README and docs props tables are updated.bun run typecheckbun run test:harness:ios: 120/120. Two new keyboard tests: the keyboard goes after a pop to a screen whose field does not take it (it failed before the fix, with a 3 s hold), and it stays for a covered field that takes it back. The Harness can't load worklets, sofocusedValueitself was checked in Uno (below).Release as 0.3.5 (the changelog heading is already
## 0.3.5).🤖 Generated with Claude Code