https://kotlinlang.org logo
#compose
Title
# compose
g

galex

08/16/2022, 10:24 AM
I have a form made of multiple
TextField
s and we hide and show those depending on some conditions. I wonder how to manage correctly the "next button" of the keyboard 🤔 If a
TextFied
is inside
AnimatedVisibility() {}
, when not visible, is it part of the composition still or not? Will the keyboard go to the next one?
s

Stylianos Gakis

08/16/2022, 11:30 AM
If I were to guess, the
TextField
will not exist in composition after it has animated out. But during animating in or out it will be, so that may be tricky in some cases. What have you tried so far? Is it not working now? This seems to be the official documentation of how to handle focus and next/previous items yourself. https://developer.android.com/reference/kotlin/androidx/compose/ui/focus/FocusProperties.
d

Doris Liu

08/16/2022, 6:11 PM
Stylianos is correct, anything in
AnimatedVisibility
is removed from the tree once the exit animations are finished. If your goal is to skip the content that is being animated out, you'll need to handle the focus yourself. The focus system doesn't have any idea which item is transient and disappearing.
g

galex

08/17/2022, 7:25 AM
Thank you both @Doris Liu and @Stylianos Gakis, We're going to investigate more deeply and manage the focus ourselves 😊
5 Views