dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
21.9k stars 1.69k forks source link

[Android] SemanticProperties.HeadingLevel not working in ListView #21830

Open ramonB1996 opened 3 months ago

ramonB1996 commented 3 months ago

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

  1. Clone: https://github.com/ramonB1996/MauiListViewA11yIssue
  2. Enable Talkback
  3. 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

ninachen03 commented 3 months ago

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.

jsuarezruiz commented 3 months ago

Did you try with the CollectionView?

ramonB1996 commented 3 months ago

@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.

BlotskiyDmitriy commented 3 months ago

@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

ramonB1996 commented 3 months ago

@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.

BlotskiyDmitriy commented 3 months ago

@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