-
Notifications
You must be signed in to change notification settings - Fork 236
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
| "getIsTransparent", | ||
| "getIsTransparent\$ui_release" | ||
| ) | ||
| for (name in candidateGetterNames) { |
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.
Feels like this is near inner loop; executed on all nodes. I should be possible to cache this reflection filter query (companion object by lazy? because it's not dependent on any specific node) and only doing the invoke in hasZeroAlpha.
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.
fair enough, we now cache the resolved function
f88856d to
2618567
Compare
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.