Handling keyboard open / close state. ```val keyb...
# compose-android
k
Handling keyboard open / close state.
Copy code
val keyboard = LocalSoftwareKeyboardController.current
val focusRequester = remember { FocusRequester() }

LaunchedEffect(Unit) {
    focusRequester.requestFocus()
    keyboard?.show()
}
Thoughts on handling keyboard open using a LaunchedEffect when we navigate to a new screen. I observed that some times if we navigate too quickly(back and forth), the screen is completely blank. and nothing happens even if hardware back button is clicked. • What should be a safe way to open / hide the keyboard, when we navigate to another screen. • Thoughts on using awaitFrame, but given that it's android only API, looking for something that will work with Compose Multiplatform.
Also wondering if it is possible to sync keyboard open/close with Shared Element Transition on the TextField ?
z
You never want to use
awaitFrame
with compose on any platform, always `withFrameNanos`/`withFrameMillis`
👍 1
None of the code you posted should have anything to do with a screen being blank, that sounds like a separate issue
👍 1
k
Thanks @Zach Klippenstein (he/him) [MOD], do you also have some suggestions for syncing keyboard open/close with Shared Element Transition on the TextField ? The UX from video I shared above is not smooth when navigating back and forth quickly.
z
I have no idea about the interaction between insets and SET. @Doris Liu has probably thought about it though
👍 1