You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 1, 2024. It is now read-only.
Accessibility values add to a Xamarin Forms Switch control are being rendered as visible text on Android.
Steps to Reproduce
Create a new cross platform Xamarin Forms app
Add a Switch to MainPage.xaml's layout
Set AutomationProperties.IsInAccessibleTree="true" on the Switch
Set AutomationProperties.Name and or AutomationProperties.HelptText values on the Switch
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
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.
Description
Accessibility values add to a Xamarin Forms Switch control are being rendered as visible text on Android.
Steps to Reproduce
AutomationProperties.IsInAccessibleTree="true"on the SwitchAutomationProperties.Nameand orAutomationProperties.HelptTextvalues on the SwitchExpected Behavior
Accessibility text should not be visible in the UI.
Actual Behavior
Observe the values set for
AutomationProperties.Nameand orAutomationProperties.HelpTextrender as a text to the left of the Switch. If both are added, both will appear in concatenated form.Basic Information
Screenshots
Reproduction Link
test.zip
Comments
Per the documentation here on Accessibility Values, Name and or HelpText should ultimately end up as the
ContentDescriptionof an Android UI control but in this case,Hinton the control is being set to this value rather thanContentDescriptionwhich 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 theSetHintmethod that if the control is aTextView, it will set the control's accessibility name and help text as the hint. If this method succeeds,SetContentDescriptionwill never set the control'sContentDescription. BothAndroid.Widget.SwitchandAndroid.Widget.SwitchCompatderive fromTextViewso a simple check of the control being aTextViewas to whether to set theHintorContentDescriptionis flawed.