-
Couldn't load subscription status.
- Fork 1.3k
Closed
Labels
Description
I'm trying to create a simple DropDownMenu with an IconButton to expand it, but when expanded is true, and we click on the icon button, onDismissRequest is called in the first place but onClick of the icon button is also called. I tried the same thing on Android and the onClick function is not called.
I don't know if it has to be different on Desktop but I can't figure it out a solution to this problem.
Here is a simplified version of my code:
@Composable
fun dropDownMenu() {
val expanded = remember { mutableStateOf(false) }
Row {
Text("label")
IconButton(
onClick = { expanded.value = !expanded.value }
) {
Icon(
painter = when (expanded.value) {
true -> getIcon("expand_less")
false -> getIcon("expand_more")
}
)
}
}
DropdownMenu(
expanded = expanded.value,
onDismissRequest = { expanded.value = false }
) {
DropdownMenuItem(onClick = {}) {
Text("content")
}
}
}