-
-
Notifications
You must be signed in to change notification settings - Fork 129
feat: sync layout from JS #1213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
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
Contributor
|
|
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
… TS issues and I can not see if solution is reliable and can pass e2e tests)
26e7c98 to
c14bf7a
Compare
Contributor
📊 Package size report
|
kirillzyusko
commented
Nov 24, 2025
android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardControllerViewManager.kt
Show resolved
Hide resolved
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
documentation
Improvements or additions to documentation
e2e
Anything about E2E tests
enhancement
New feature or request
focused input 📝
Anything about focused input functionality
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.
📜 Description
Added an ability to have a bi-directional communication and read/update layout from JS on demand.
💡 Motivation and Context
This PR adds a command that we can dispatch from JS in order to get an actual layout of focused input. The task sounds pretty simple, but I anyway had some problems, and would like to describe solutions from them here.
First of all the querying of layout is an async operation and we need to wait for completion before running a worklet code (so that we can be sure, that event has been actually dispatched and shared-value has up-to-date value). But default mechanism for view commands not suppose to return any kind of data back to the JS thread. Alternative option is to define "module" method and return the data/completion status from there. However in new architecture it is highly not recommended to use such approach, because this approach relies on RN internals that can be changed/removed from the future. So I decided to go with recommended approach. To overcome asynchronous stuff I decided to set one-time listener and resolve a promise when I get specific
layoutDidSynchronizeevent - this is not a perfect solution but does a job for now and doesn't use deprecated stuff, so I'm pretty happy.On a high level overview - we pass
updatefunction through thecontext, becausecontexthas an access toKeyboardControllerViewand from there we dispatch/wait.Also I decided to expose
assureFocusedInputVisiblemethod forKeyboardAwareScrollView. In the past I had requirements to scroll a little bit when validation error appears, and back to the time I just hard-coded it likeref.current.scrollTo(50), but of course this fix didn't handle all the cases. Now it's just enough to callref.current.assureFocusedInputVisible()and enjoy pixel perfect automatic calculations 😎And in the end I decided to cover new functionality with e2e tests so that we will not break them accidentally in the future 🤞
Closes #1208
📢 Changelog
Docs
updatemethod;assureFocusedInputVisiblemethod of ref;E2E
KeyboardAwareScrollView;JS
synchronizeFocusedInputLayoutcommand forKeyboardControllerView;KeyboardController::layoutDidSynchronizeevent;assureFocusedInputVisiblemethod forKeyboardAwareScrollView;iOS
synchronizeFocusedInputLayoutcommand for paper/fabric;Android
synchronizeFocusedInputLayoutcommand for paper/fabric;🤔 How Has This Been Tested?
Tested manually on iPhone 16 Pro (iOS 26.0)/Pixel 6 Pro (API 31, 35) both paper/fabric.
📸 Screenshots (if appropriate):
Screen.Recording.2025-11-25.at.13.02.03.mov
Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-11-25.at.13.00.08.mov
📝 Checklist