Skip to content

Instantly share code, notes, and snippets.

@dladukedev
Created July 21, 2023 13:17
Show Gist options
  • Save dladukedev/b360e53e1adeef7f049d068a6d9f290c to your computer and use it in GitHub Desktop.
Save dladukedev/b360e53e1adeef7f049d068a6d9f290c to your computer and use it in GitHub Desktop.
Overview of how TalkBack interprets Different Semantic Modifiers
// Reads "One" -> "Two" -> "Three"
Row(modifier = Modifier.semantics(mergeDescendants = false) { }) {
Text("One")
Column {
Text("Two")
Text("Three")
}
}
// Reads "One Two Three"
Row(modifier = Modifier.semantics(mergeDescendants = true) { }) {
Text("One")
Column {
Text("Two")
Text("Three")
}
}
// Reads "One" -> "Two Three"
Row(modifier = Modifier.semantics(mergeDescendants = true) { }) {
Text("One")
Column(modifier = Modifier.semantics(mergeDescendants = true) { }) {
Text("Two")
Text("Three")
}
}
// Reads "Custom Description One Two Three"
Row(modifier = Modifier.semantics(mergeDescendants = true) {
contentDescription = "Custom Description"
}) {
Text("One")
Column {
Text("Two")
Text("Three")
}
}
// Reads "Custom Description"
Row(modifier = Modifier.clearAndSetSemantics {
contentDescription = "Custom Description"
}) {
Text("One")
Column {
Text("Two")
Text("Three")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment