Assigned
Status Update
Comments
so...@google.com <so...@google.com> #2
Hello, can you please attach a sample that reproduces your error?
he...@ataulm.com <he...@ataulm.com> #3
I’ve attached two screen recordings demonstrating the mediator's behavior during the first and second launches after installation. Additionally,
Description
Description
I'm looking for a new API/enhancement to an existing API that will mimic ViewGroup.setContentDescription on a clickable ViewGroup. Today, there are 3 approaches to setting content descriptions with Compose:
semantics { contentDescription = "blah" }
semantics(mergeDescendants = true) { contentDescription = "blah" }
clearAndSetSemantics { contentDescription = "blah" }
None of these mimic ViewGroup.setContentDescription on a clickable ViewGroup, where descendant widgets would be ignored unless they're clickable/focusable.
The second one is the one which I expected would behave this way, but it concatenates content descriptions of descendant nodes (as explained in the well-written docs for that API), even if they're not clickable.
Since Jetpack Compose is stable, it's not possible to change the current behavior, so I am requesting another mechanism which achieves the same.
Use Case
For complex widgets (e.g. a Tweet), especially in organizations with separate teams working on the same codebase, crafting and setting an explicit content description is preferable to relying on the framework's implicit concatenation.
An example with a simple widget:
In this example, we'd want to set an explicit content description on the
Row
, but leave the Button as-is (focusable, clickable).If we use
clearAndSetSemantics()
, we can set the description (without getting "User" and "Message" concatenated onto it), but then we lose the button.The only workaround today is to use
clearAndSetSemantics {}
on each of the Text nodes.Here they're grouped together so we could clear the semantics on the column, but it's a contrived example - it would be easy to consider a case where there are many text elements which are not contiguous.
Some API like this would be much preferred:
where
keepSemantics()
is very explicit and can be used to mark important elements which should not lose their semantics.