https://kotlinlang.org logo
Title
c

Colton Idle

06/22/2022, 8:18 PM
I have an ExposedDropDownMenu that is extremely laggy delayed when opening. It takes like a good 4 seconds (and yes this happens in release builds too). I have a bunch of items (it's a country picker actually). My idea was "I know lets make it Lazy" but that leads to a crash. Any ideas from anyone?
r

ryan.fonzi

06/22/2022, 10:03 PM
Not a perfect solution, but as a workaround you can just keep the dropdown closed on blank inputs. Once they start typing, the list of countries you're dealing with is already massively reduced by filtering.
c

Colton Idle

06/22/2022, 10:04 PM
Ooh. We don't actually support filtering. Just a plain old drop down right now
f

Francesc

06/22/2022, 10:15 PM
I haven't tried this, but what if you specify a height to the
ExposedDropDownMenu
to satisfy the lazy list requirement?
a

Albert Chang

06/23/2022, 1:49 AM
Use lazy list and give it a fixed width.
c

Colton Idle

06/23/2022, 2:34 AM
Interesting. Can I just use the default width for these things? Or is that the point (that the width changes depending on the item)?
a

Albert Chang

06/23/2022, 2:39 AM
There is no default width. See this thread.
‼️ 1
s

saket

06/23/2022, 4:23 AM
I'm curious: do you see any perf difference if you try out cascade?
c

Colton Idle

06/23/2022, 6:10 AM
oooh. I thought cascade was only for like action overflow, not necessarily for your "standard" drop down selector list. If it is in fact for a normal drop down, then I'd love to give it a whirl. love the smooth anims ❤️
s

saket

06/23/2022, 1:05 PM
It's actually not designed to be used as an exposed dropdown but I'm interested in seeing if it's perf is any different 😄.
c

Colton Idle

06/23/2022, 5:46 PM
will give it a try later on!
Circled back to this today and I get the same crash. If I add a height to the lazy column, then I dont crash... but then it doesn't scroll. 😄 Thoughts?
ExposedDropdownMenu(expanded = expanded, onDismissRequest = { expanded = false }) {
    LazyColumn(Modifier.width(100.dp)){
        itemsIndexed(list) { index, selectionOption ->
            DropdownMenuItem(
                onClick = {
                    selected(index)
                    expanded = false
                }) {
                    Text(text = selectionOption)
r

ryan.fonzi

06/28/2022, 4:37 AM
Yep, same here. I wonder if the nested scrolling is doing something weird. The only other thing I can think of which probably works (but is overkill) is copying the implementation of
ExposedDropdownMenu
and replacing the use of
Column
internally with
LazyColumn
.
c

Colton Idle

06/28/2022, 5:43 PM
@Adam Powell sorry for the ping, but you commented on the previous thread that Albert dropped in here. Do you have any idea how to use an ExposedDropDownMenu with LazyColumn.
👀 1