diff options
author | Eric Maupin <ermaup@microsoft.com> | 2019-11-07 23:07:51 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-07 23:07:51 +0300 |
commit | a81ae7cfb70a2920b7838ff40c19b85cb4d56bf9 (patch) | |
tree | 19f08e0ae621c0e284e0cfcd49d7e7a68c213887 | |
parent | 8790fdf0dad435fae13a3a3e79e0a066e83c7945 (diff) | |
parent | 6a38f3b7f86964e4965f243d2dc3a5865da0a3ec (diff) |
Merge pull request #679 from xamarin/bret-handle-colon-in-automation-group-name
Fix a11y bug 999307
-rw-r--r-- | Xamarin.PropertyEditing.Tests/MockControls/MockSampleControl.cs | 1 | ||||
-rw-r--r-- | Xamarin.PropertyEditing.Windows/CombinablePredefinedValuesEditorControl.cs | 21 |
2 files changed, 22 insertions, 0 deletions
diff --git a/Xamarin.PropertyEditing.Tests/MockControls/MockSampleControl.cs b/Xamarin.PropertyEditing.Tests/MockControls/MockSampleControl.cs index b236d99..991ef5b 100644 --- a/Xamarin.PropertyEditing.Tests/MockControls/MockSampleControl.cs +++ b/Xamarin.PropertyEditing.Tests/MockControls/MockSampleControl.cs @@ -37,6 +37,7 @@ namespace Xamarin.PropertyEditing.Tests.MockControls }); AddProperty<FlagsNoValues> ("FlagsNoValues", ReadWrite, canWrite: true, flag: true); AddProperty<FlagsWithValues> ("FlagsWithValues", ReadWrite, canWrite: true, flag: true); + AddProperty<FlagsWithValues> ("prefix:FlagsWithColonInLabel", ReadWrite, canWrite: true, flag: true); AddProperty<CommonPoint> ("Point", ReadWrite, isUncommon: true); AddProperty<CommonSize> ("Size", ReadWrite, isUncommon: true); AddProperty<CommonRectangle> ("Rectangle", ReadWrite); diff --git a/Xamarin.PropertyEditing.Windows/CombinablePredefinedValuesEditorControl.cs b/Xamarin.PropertyEditing.Windows/CombinablePredefinedValuesEditorControl.cs index f259bd9..8e61a68 100644 --- a/Xamarin.PropertyEditing.Windows/CombinablePredefinedValuesEditorControl.cs +++ b/Xamarin.PropertyEditing.Windows/CombinablePredefinedValuesEditorControl.cs @@ -4,6 +4,8 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; +using System.Windows.Automation; +using Xamarin.PropertyEditing.ViewModels; namespace Xamarin.PropertyEditing.Windows { @@ -15,5 +17,24 @@ namespace Xamarin.PropertyEditing.Windows DefaultStyleKeyProperty.OverrideMetadata (typeof (CombinablePredefinedValuesEditor), new FrameworkPropertyMetadata (typeof (CombinablePredefinedValuesEditor))); FocusableProperty.OverrideMetadata (typeof(CombinablePredefinedValuesEditor), new FrameworkPropertyMetadata (false)); } + + public override void OnApplyTemplate () + { + base.OnApplyTemplate (); + + // Windows has the surprising behavior that when an automation group (like a group of combinable checkboxes) + // has a colon in the name, the group label is not read by the narrator. This causes a problem for the Android + // designer, which has property names like "app:layout_anchorGravity". We work around this by replacing the + // colon with a space in the group's automation name. + var propertyPresenter = this.FindParent<PropertyPresenter> (); + if (propertyPresenter != null) { + var name = (propertyPresenter.DataContext as PropertyViewModel)?.Name; + + if (name != null && name.Contains (":", StringComparison.Ordinal)) { + var automationName = name.Replace (':', ' '); + AutomationProperties.SetName (propertyPresenter, automationName); + } + } + } } } |