[UWP,iOS] Enable screen readers to read non-interactive elements (#2876) fixes #1946

* [iOS] Default IsAccessibilityElement to true

* Update a11y gallery for new expectations

* [UWP] Don't override OnCreateAutomationPeer on LabelRenderer

This was added in #1067 to enable automated UI tests, but it has drastic effects on the Narrator and will need to be revisited.

fixes #1946
This commit is contained in:
Samantha Houts 2018-06-03 19:19:46 -07:00 коммит произвёл Rui Marinho
Родитель a2d82b5de0
Коммит 1a70c1325b
3 изменённых файлов: 20 добавлений и 14 удалений

Просмотреть файл

@ -91,10 +91,6 @@ namespace Xamarin.Forms.Controls
image.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => DisplayAlert("Success", "You tapped the image", "OK")) });
image.SetAutomationPropertiesName(ImageName);
image.SetAutomationPropertiesHelpText(ImageHelpText);
// Images are ignored by default on iOS (at least, Forms Images are);
// make accessible in order to enable the gesture and narration
image.SetAutomationPropertiesIsInAccessibleTree(true);
var instructions6 = new Label { Text = boxInstructions };
var boxView = new BoxView { Color = Color.Purple };
@ -102,7 +98,7 @@ namespace Xamarin.Forms.Controls
boxView.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => DisplayAlert("Success", "You tapped the box", "OK")) });
boxView.SetAutomationPropertiesName(BoxName);
boxView.SetAutomationPropertiesHelpText(BoxHelpText);
// BoxViews are ignored by default on iOS and Win;
// BoxViews are ignored by default on Win;
// make accessible in order to enable the gesture and narration
boxView.SetAutomationPropertiesIsInAccessibleTree(true);

Просмотреть файл

@ -35,16 +35,20 @@ namespace Xamarin.Forms.Platform.UWP
SizeRequest _perfectSize;
bool _perfectSizeValid;
protected override AutomationPeer OnCreateAutomationPeer()
{
// We need an automation peer so we can interact with this in automated tests
if (Control == null)
{
return new FrameworkElementAutomationPeer(this);
}
//TODO: We need to revisit this later when we complete the UI Tests for UWP.
// Changing the AutomationPeer here prevents the Narrator from functioning properly.
// Oddly, it affects more than just the TextBlocks. It seems to break the entire scan mode.
return new FrameworkElementAutomationPeer(Control);
}
//protected override AutomationPeer OnCreateAutomationPeer()
//{
// // We need an automation peer so we can interact with this in automated tests
// if (Control == null)
// {
// return new FrameworkElementAutomationPeer(this);
// }
// return new TextBlockAutomationPeer(Control);
//}
protected override Windows.Foundation.Size ArrangeOverride(Windows.Foundation.Size finalSize)
{

Просмотреть файл

@ -205,6 +205,12 @@ namespace Xamarin.Forms.Platform.MacOS
{
#if __MOBILE__
_defaultColor = uiview.BackgroundColor;
// UIKit UIViews created via storyboard default IsAccessibilityElement to true, BUT
// UIViews created programmatically default IsAccessibilityElement to false.
// We need to default to true to allow all elements to be accessible by default and
// allow users to override this later via AutomationProperties.IsInAccessibleTree
uiview.IsAccessibilityElement = true;
#else
uiview.WantsLayer = true;
_defaultColor = uiview.Layer.BackgroundColor;