Hey again, I’m having some trouble with `Modifier....
# compose
j
Hey again, I’m having some trouble with
Modifier.onFocusEvent
Say I have a scrollable list of buttons and at the very bottom of this list I have a
OutlinedTextField
. I’ve applied the following to the
OutlinedTextField
Copy code
.onFocusEvent {
    if (it.isFocused) {
        scope.launch { scrollState.animateScrollTo(scrollState.maxValue) }
    }
}
This works as expected in that when I tap on the
OutlinedTextField
, my list scrolls to the bottom. The issue is that even when I tap on other elements (i.e. one of the buttons), that also scrolls the user to the bottom. Any ideas?
w
I’d put a breakpoint and see if it is actually calling this method, and if so, what “it” is in this case. It’s possible that your scrollable list is reusing views, and you’ll need to qualify your “it” to make sure you’re interacting with the element you think you are.
👍 1