https://kotlinlang.org logo
Title
r

Rihards

03/01/2023, 10:10 AM
Hi! I’m trying to implement keyboard closure when user is scrolling outside the keyboard, but I’m not able to write something (keyboard is opened and immediately closed) if I check
rememberScrollState().isScrollInProgress
value and execute
LocalFocusManager.current.clearFocus()
when scroll is in progress. What’s the recommended way to handle keyboard closure in this situation?
My solution:
LaunchedEffect(Unit) {
            snapshotFlow { scrollState.value }.collect {
                focusManager.clearFocus()
            }
        }