Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug] Xamarin Forms Accessibility for the Layout<View> child ContentView label text not working. #13796

Closed
jeyakasipandi opened this issue Feb 18, 2021 · 3 comments
Labels
a/a11y 🔍 a/label s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. t/bug 🐛

Comments

@jeyakasipandi
Copy link

jeyakasipandi commented Feb 18, 2021

Description

We have created a custom Layout to add the ContentView Label when select the view label text not accessible.

[XAML]

    <local:CustomView AutomationId="CustomLayout" VerticalOptions="Center"  HeightRequest="300" WidthRequest="300" BackgroundColor="Aqua" >
        <ContentView BackgroundColor="Yellow" HeightRequest="300" WidthRequest="300">
            <Label Text="LabelText" FontSize="25" HorizontalOptions="CenterAndExpand" VerticalTextAlignment="Center"/>
        </ContentView>
    </local:CustomView>

[C#]

    public class CustomView : StackLayout
    {
        public CustomView()
        {
            this.SetValue(AutomationProperties.IsInAccessibleTreeProperty, true);

            AutomationProperties.SetName(this, this.AutomationId + "LayoutItem 1 of 1");
        }
}

If enable IsInAccessibleTreeProperty for both the CustomView and ContentView. The voice over will be only Label text.

Expected Behavior

While select the view the voice over should be LabelText + LayoutItem 1 of 1.

Actual Behavior

The child view text not accessible.

Basic Information

XF version 4.8

Environment

Visual Studio 2019

Screenshots

image

Sample LInk

Accessibilitydemo.zip

@jeyakasipandi jeyakasipandi added s/unverified New report that has yet to be verified t/bug 🐛 labels Feb 18, 2021
@samhouts samhouts added this to New in Triage Feb 18, 2021
@rachelkang rachelkang added a/label and removed s/unverified New report that has yet to be verified labels Feb 19, 2021
@rachelkang rachelkang moved this from New to Ready For Work in Triage Feb 19, 2021
@rachelkang rachelkang added this to Backlog in Accessibility via automation Feb 19, 2021
@rachelkang
Copy link
Contributor

Hi, @jeyakasipandi - thanks for submitting this issue. I'm confirming I'm able to reproduce this behavior on both Android and iOS, even on the latest version of XF 5.0.0.2012.

As you described - For some reason, the default is that the child subview is accessible while the parent view is not - yet, setting IsInAccessibilityTree="True" on the parent view is making the parent view accessible while making the child subviews inaccessible. It seems that setting IsInAccessibilityTree="True" directly on the child view makes it accessible again on Android, but not iOS. Further exploration is needed to understand why this is the case.

This issue is also not limited just to custom views. The same issue was reproduced without the custom view:

<StackLayout AutomationProperties.IsInAccessibleTree="True" AutomationProperties.Name="LayoutItem 1 of 1">
     <ContentView BackgroundColor="Yellow" HeightRequest="300" WidthRequest="300">
             <Label Text="LabelText" FontSize="25" HorizontalOptions="CenterAndExpand" VerticalTextAlignment="Center" /> 
     </ContentView>
</StackLayout>

@Redth Redth moved this from Ready For Work to Needs Estimate in Triage Mar 4, 2021
@rachelkang
Copy link
Contributor

Hi, @jeyakasipandi - in order to achieve the before you want, you may be able to leverage the all-new SemanticOrderView from Xamarin Community Toolkit or even use different layouts (i.e. Grid) to layer the controls.

If you haven't already, I also recommend updating to the latest version Xamarin.Forms or at least to Xamarin.Forms 5.0.0.2083, which has many accessibility improvements. These improvements include an experimental accessibility flag that addresses a lot of improvements in Android accessibility.

To leverage this flag on the latest versions of Xamarin Forms, the following code can be inserted in the App.xaml.cs file, following the InitializeComponent call and before the MainPage is set: Xamarin.Forms.Device.SetFlags(new List<string> { "Accessibility_Experimental"});

@rachelkang rachelkang added the s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. label Jan 7, 2022
@jfversluis
Copy link
Member

Assuming this is resoled with the information that was provided by us

Triage automation moved this from Needs Estimate to Closed Mar 10, 2022
Accessibility automation moved this from Backlog to Done Mar 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a/a11y 🔍 a/label s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. t/bug 🐛
Projects
Accessibility
  
Done
Triage
  
Closed
Development

No branches or pull requests

4 participants