DropDown menu not clickable when expanded
I have created an app and added a component which is a drop down list. It use to work but I cannot make it work again. When I click on the item, the click is not caught.
The code is as below:
@Composable
fun SortedBySelector(viewModel: MainViewModel) {
var expanded by remember { mutableStateOf(false) }
var selectedType by remember { mutableStateOf(SortedBy.BY_DATE) }
Box(
modifier = Modifier
) {
Row(modifier = Modifier
.clickable { expanded = !expanded }
) {
Text(selectedType.value)
if(expanded) {
Icon(Icons.Default.KeyboardArrowUp, contentDescription = "Arrow Up")
} else {
Icon(Icons.Default.KeyboardArrowDown, contentDescription = "Arrow Down")
}
}
DropdownMenu(
expanded = expanded,
onDismissRequest = { expanded = false },
containerColor = MaterialTheme.colorScheme.background
) {
listOfSortedBy.forEach {
DropdownMenuItem(
text = { Text(it.value) },
onClick = {
expanded = !expanded
selectedType = it
viewModel.refreshCategory(it)
}
)
}
}
}
}
Any idea why ? I cannot figure-out. The issue is on the emulator.
Source: View source