-
Notifications
You must be signed in to change notification settings - Fork 237
A11y renderer: handle nodes with alpha=0f or HideFromAccessibility #2094
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| private fun SemanticsNode.hasZeroAlpha(): Boolean { | ||
| // try to reflectively query internal SemanticsNode.isTransparent() by iterating on kotlin field mangled names: | ||
| val candidateGetterNames = arrayOf( | ||
| "isTransparent", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very ugly, unless there is an alternative way to get this info, we should get Compose to expose this property
paparazzi/src/main/java/app/cash/paparazzi/accessibility/AccessibilityRenderExtension.kt
Outdated
Show resolved
Hide resolved
f88856d to
2618567
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this dropdown is detected as transparent. That's not ideal, but the "before" screenshot is also incorrect and does not display the dropdown content, so the after is technically correct.
This happens because DropdownMenu is a Popup and AFAIK paparazzi can only render content in the main window
The ideal state would be to display both windows, but that's out of the scope of this PR.
|
@TWiStErRob no hurry, but could I get another review on this? Ideally, if that PR looks good, then it would be nice to get it included in alpha3 🙏 |
Ugly fix for #2093
The current approach to check for
modifier == Modifier.alpha(0f)only works if you use this exact modifier.In particular,
Modifier.graphicsLayer { alpha = 0f }won't match this check.Unfortunately, Compose does not really expose anything that we could use to identify a transparent node.
There is however an internal function allowing us to detect this.
Ideally we would get the compose team to make it public (or otherwise expose this information another way), but in the mean time I have written this ugly reflective way to access this information
This also adds a check for
HideFromAccessibilitysince this is a new replacement forInvisibleToUser, we need to check for that one too.