Trying to set the accessibility content descriptio...
# compose
c
Trying to set the accessibility content description with the
Modifier.semantics{}
on the DropDownMenu component, but TalkBack seems to read out the panel package and activity name. Any ideas of how to get around it? Code in 🧵
Copy code
@Composable
fun Menu() {
  var expanded by remember  {mutableStateOf(false) }
  var text by remember { mutableStateOf("Pick an option") }
  var firstOption by remember { mutableStateOf(false) }
  var secondOption by remember { mutableStateOf(false) }
  var thirdOption by remember { mutableStateOf(false) }
  Box{
    Button (onClick = {expanded = true}){
      text = when {
        firstOption -> "First Option"
        secondOption -> "Second Option"
        thirdOption -> "Third Option"
        else -> "Pick an option"
      }
      Text(text)
    }
    DropdownMenu(
      expanded = expanded,
      onDismissRequest = { expanded = false},
      modifier = Modifier
        .semantics { 
          contentDescription = "Pop up"
        }
    ) {
      DropdownMenuItem(onClick = {
        expanded = false
        firstOption = true
        secondOption = false
        thirdOption = false
      }) {
        Text("Option 1")
      }
      DropdownMenuItem(onClick = {
        expanded = false
        firstOption = false
        secondOption = true
        thirdOption = false
      }) {
        Text("Option 2")
      }
      DropdownMenuItem(onClick = {
        expanded = false
        firstOption = false
        secondOption = false
        thirdOption = true
      }) {
        Text("Option 3")
      }
    }
  }
}