DropDown menu not clickable when expanded

PressRex profile image
by PressRex
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

PressRex profile image
by PressRex

Subscribe to New Posts

Lorem ultrices malesuada sapien amet pulvinar quis. Feugiat etiam ullamcorper pharetra vitae nibh enim vel.

Success! Now Check Your Email

To complete Subscribe, click the confirmation link in your inbox. If it doesn’t arrive within 3 minutes, check your spam folder.

Ok, Thanks
Could not load content

Latest posts