Im working with Jetpack Compose and having a ModalBottomSheetLayout with a TextField. While Closing the bottom sheet, the keyboard it not going off.
Keyboard should hide, when ModalBottomSheetLayout dismisses.
@OptIn(ExperimentalMaterialApi::class)
@Composable
fun ModalBottomSheetSample() {
val state = rememberModalBottomSheetState(initialValue = ModalBottomSheetValue.Hidden,)
val scope = rememberCoroutineScope()
BackHandler(state.isVisible) {
scope.launch {state.hide()}
}
ModalBottomSheetLayout(sheetState = state, sheetContent = {
TextField(value = "",
onValueChange = {},
placeholder = { Text(text = "Search") },
modifier = Modifier
.padding(10.dp)
.fillMaxWidth()
)
LazyColumn {items(50) {...}}
}) {
Button(onClick = { scope.launch { state.show() } }) {
Text("Click to show sheet")
}
}
}
have referred this question, but this is not applicable for this scenario. As this is based on Composable.