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

Accessibility Name or HelpText properties added to Switch are visible in Android UI #3208

@roberleitner

Description

@roberleitner

Description

Accessibility values add to a Xamarin Forms Switch control are being rendered as visible text on Android.

Steps to Reproduce

  1. Create a new cross platform Xamarin Forms app
  2. Add a Switch to MainPage.xaml's layout
  3. Set AutomationProperties.IsInAccessibleTree="true" on the Switch
  4. Set AutomationProperties.Name and or AutomationProperties.HelptText values on the Switch
  5. Run in any Android Device or Simulator

Expected Behavior

Accessibility text should not be visible in the UI.

Actual Behavior

Observe the values set for AutomationProperties.Name and or AutomationProperties.HelpText render as a text to the left of the Switch. If both are added, both will appear in concatenated form.

Basic Information

  • Version with issue: 3.0, 3.1, and current latest master branch
  • Last known good version: N/A
  • IDE: Visual Studio 15.7.4 Windows, Visual Studio for Mac 7.5.3 build 7
  • Platform Target Frameworks:
    • iOS: N/A
    • Android: 8.1
    • UWP: N/A
  • Android Support Library Version: v4, v7
  • Nuget Packages:
  • Affected Devices: Google Nexus 5X; Android Emulators 8.1, 7.1.1, 4.4

Screenshots

screen shot 2018-07-03 at 2 05 49 pm

Reproduction Link

test.zip

Comments

Per the documentation here on Accessibility Values, Name and or HelpText should ultimately end up as the ContentDescription of an Android UI control but in this case, Hint on the control is being set to this value rather than ContentDescription which I suppose is why it is rendering in the UI.

I cloned the latest Xamarin Forms project and created my own nuget package to debug the issue. What I am seeing is in AutomationPropertiesProvider, there is a check in the SetHint method that if the control is a TextView, it will set the control's accessibility name and help text as the hint. If this method succeeds, SetContentDescription will never set the control's ContentDescription. Both Android.Widget.Switch and Android.Widget.SwitchCompat derive from TextView so a simple check of the control being a TextView as to whether to set the Hint or ContentDescription is flawed.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions