When composable decompose and there was focused in...
# compose
p
When composable decompose and there was focused input with keyboard opened, then keyboard stayed opened. How to force close keyboard on such case?
r
The `DisposableEffect`’s
onDispose
lambda is called when the Composable leaves the composition. I.e. put something like this on the screen/widget where you want to close the keyboard when the screen/widget is closed.
Copy code
val textInputService = LocalTextInputService.current
DisposableEffect(Unit) {
    onDispose { 
        textInputService.hideSoftwareKeyboard()
    }
}
p
Thanks! It works!