I have a MyBasicTextField in a composable to request user input:
@Composable
fun MyBasicTextField() {
val keyboardController = LocalSoftwareKeyboardController.current
val focusRequester = remember{ FocusRequester() }
BasicTextField(
modifier = Modifier
.focusRequester(focusRequester),
keyboardActions = keyboardActions ?: KeyboardActions(onAny = { keyboardController?.hide() }),
)
LaunchedEffect(Unit) {
focusRequester.requestFocus()
}
}
The keyboard automatically slides in when showing this composable, always.
But wherever MyBasicTextField
is used:
- I tap on a LinkifiedText to leave and open a browser to show link
- I tap BACK
- and come back to previous MyBasicTextField screen, the keyboard is not shown
- also the
focusRequester.requestFocus()
is not triggered again when coming back
How can I solve my issue?