What’s the expected behavior for components that m...
# compose
z
What’s the expected behavior for components that merge their semantics but have children with content descriptions? It seems like the content description just gets dropped in the merged tree. So e.g. if you have an image inside a clickable, the image’s content description is hidden when reading the merged semantics tree. This seems to work fine for accessibility – talkback will read the content description – but for UI tests, you have to pass
useUnmergedTree=true
to the node matcher, which seems unintuitive.
🐛 1
So e.g. given this code:
Copy code
IconButton(Modifier.testTag("button") {
  Icon(…, contentDescription = "the button icon")
}
Since
IconButton
uses
clickable
it merges its semantic descendents. So it would seem intuitive to write a test like this for it:
Copy code
onNodeWithTag("button").assertContentDescriptionEquals("the button icon")
However that test fails, because the content description property is nowhere to be found in the merged tree. That seems intuitive to me because it works for text. Given:
Copy code
Button(Modifier.testTag("button")) { Text("text") }
This test passes:
Copy code
onNodeWithTag("button").assertTextEquals("text")
because the merged semantics node identified by the tag “button” actually has its own
Text
property, merged in from the child. Content description does not work this way – seems like a bug to me, but I could be thinking of “content description” in the wrong way.
I don’t see anything in the docs about this particular behavior.