I had prepared a `AutoCompleteTextField` few days ago but with the latest compose (alpha09) it seems...
k
I had prepared a
AutoCompleteTextField
few days ago but with the latest compose (alpha09) it seems like it's a bad idea to put a TextField inside a
LazyColumn
as one of its
item
, especially when its other items are decided based on what we type in the TextField, as I found my current implementation just gets stuck in an infinite loop of recomposition, freezing the textfield. Any best practices, guidelines to follow in this regard? What should we keep inside a LazyColumn and what we shouldn't?
d
Why is the
TextField
inside the
LazyColumn
?
k
I was planning to show suggestions below it, so I thought I could use LazyColumn items for suggestion and use single
item
for TextField, as we use it for headers right now
d
Why not
Column { TextField(....); LazyColumn { ... } }
is what I'm getting at.
Or even better a
DropdownMenu
r
DropdownMenu is not good choice. Suggestions will be shown while we are typing based on the query. When drop-down shown input field loose focus automatically
d
That is configurable
r
How can we configure?
d
We own the state of the composable. So we can keep in shown when we want. https://developer.android.com/reference/kotlin/androidx/compose/material/package-summary#dropdownmenu
expanded = true
r
I’m not asking about visibility state. How can we prevent focus change of input field when dropdown shown ?
d
Ah I see. No idea, haven't used it much.
k
I'm trying to implement a validator for AutoCompleteTextField (only items from a List are allowed) and I'm finding it really difficult. I hope it was available out of the box
r
@Kshitij Patil Can you share the code?
a
The issue in the OP of this thread sounds like a bug, please file it with an isolated repro if you have a few minutes. A text field inside of a LazyColumn should be alright.
k
Now it sounds fishy to me as well because I remember it used to work in
alpha07
, I'll try to create a repro when I get time and @rsktash you can also have a look at.