maui
maui copied to clipboard
[Android] SemanticProperties.HeadingLevel not working in ListView
Description
I am trying to make a Label inside a ListView accessible by using SemanticProperties.HeadingLevel="Level1". This should be used by Android Talkback and tell the user that the label is a heading. Sadly, that part seems to be ignored inside a ListView
This works correctly on iOS!
Please let me know if there are any questions :)
Steps to Reproduce
- Clone: https://github.com/ramonB1996/MauiListViewA11yIssue
- Enable Talkback
- Confirm the bug when going through the items in the list
Link to public reproduction project repository
https://github.com/ramonB1996/MauiListViewA11yIssue
Version with bug
8.0.20 SR4
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Android 12
Did you find any workaround?
Sadly, no.
In Xamarin.Forms we created an A11YEffect that added these lines of code when a label should be a heading:
ViewCompat.SetAccessibilityHeading(control, true);
if (Build.VERSION.SdkInt >= BuildVersionCodes.P)
control.AccessibilityHeading = true;
I tried doing this in a Behavior with Maui, but that did not change the outcome.
Relevant log output
No response
Verified this issue with Visual Studio 17.10.0 Preview 3 (8.0.20 &8.0.14).I can repro this issue on android(xiaomi)physical.
Did you try with the CollectionView?
@jsuarezruiz I tried my sample with a CollectionView instead. This yields the same results as with ListView. It does not work for Android, but works for iOS.
@ramonB1996 I found this problem in the maui source code. The fact is that the Heading value is not set to true when necessary. Maybe they just forgot. Also, it didn't work not only for collections, but for all controls
@BlotskiyDmitriy Thanks for creating a PR on this. However, I am pretty sure this worked on default controls like a Label. Are you sure it does not work everywhere? I thought only collections were a problem.
@ramonB1996 I added your example to the Maui Sandbox and tried to reproduce the problem with a simple Label. After setting the HeadingLevel with the TalkBack function enabled, the phrase "Heading" isn't said