:woman_with_probing_cane::ladybug:Hello, can someo...
# compose
m
👩‍🦯🐞Hello, can someone help me with an
accessibility
and
testing
problem? I have several components with accessibility requirements where I need to use
invisibleToUser
or as the
clearAndSetSemantics
api recommends so talkback ignores it completely. LINK On the other hand, I have a requirement for automatic testing where I must include
Modifier.testTag
to all my composables and they can do tests. LINK Using the
invisibleToUser
clearAndSetSemantics
modifiers removes all traces of the test semantics and you can't rewrite it since the component has so many child components each with its own testTag. In my opinion
invisibleToUser
should just remove that semantics so talkback doesn't read it but not get into the test part. Anyone having the same problem? Thanks
plus1 2
y
Hi, on our project we use following logic Modifier.semantics { if(talkbackEnabled) invisibleToUser() }
m
interesting, how do you detect if talkback is on?
The solution seems valid although it is a trick, I would like google to provide something
plus1 1
y
We created composable wrapper around AccessibilityService
m
thanks, maybe I'll adapt it to a simple boolean if the app is compiled for automated testing
@Yahor Is your composable capable of listening to on/off changes? I am able to detect if it is on but not detect changes, I try to use addAccessibilityStateChangeListener but I get nothing
y
We wrap the state change listener into separate class and emit new changes into Flow. From the compose side just use collectAsState
m
Thank you, I finally solved it and I have it now reactive
👍 1
u
Hi @mario Could you please share your solution? I am having tough time figuring out this workaround.
m
Yes, share you tomorrow.
🙏 1
u
Hi @mario, bumping in case you missed it.
m
i was share with you via PM
h
hey @mario, I'm facing the same issue (conflicts between testing and accessibility requirements). I'd appreciate it if you could share your solution with me too
u
@Hamza Kovacevic I have shared Raul’s solution with you on your DM
🤝 1