From 576d9c6a95ddb787356e12602c92b84d91ce2600 Mon Sep 17 00:00:00 2001 From: MichaelLHerman Date: Fri, 14 Jan 2022 09:25:51 -0500 Subject: [PATCH] [iOS] Picker - Fix VoiceOver reading reading row twice (#14209) * only reload picker on collection change * Add sample to projitems Co-authored-by: Mike Herman Co-authored-by: rachelkang Co-authored-by: Gerald Versluis --- .../Issue13193.cs | 58 +++++++++++++++++++ ...rin.Forms.Controls.Issues.Shared.projitems | 1 + .../Renderers/PickerRenderer.cs | 2 +- 3 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue13193.cs diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue13193.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue13193.cs new file mode 100644 index 00000000000..fe5b63f7e27 --- /dev/null +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue13193.cs @@ -0,0 +1,58 @@ +using System.Collections.Generic; +using Xamarin.Forms.CustomAttributes; +using Xamarin.Forms.Internals; + +#if UITEST +using Xamarin.UITest; +using NUnit.Framework; +using Xamarin.Forms.Core.UITests; +#endif + +namespace Xamarin.Forms.Controls.Issues +{ +#if UITEST + [Category(UITestCategories.ManualReview)] + [Category(UITestCategories.Accessibility)] +#endif + [Preserve(AllMembers = true)] + [Issue(IssueTracker.Github, 13193, + "Double prompt when voice over reads picker item on iOS", + PlatformAffected.iOS)] + public class Issue13193 : TestContentPage + { + public Issue13193() + { + } + + protected override void Init() + { + Title = "Issue 13193"; + + var layout = new StackLayout + { + Padding = 12 + }; + + var instructions = new Label + { + Text = "Turn VoiceOver on, select the picker, double-tap to edit, select the input view, and swipe up to navigate through the picker items. If an item or a truncated portion of an item is read twice, the test failed" + }; + + var picker = new Picker + { + ItemsSource = new List + { + "Bananas", + "New York", + "Grapes" + } + }; + + layout.Children.Add(instructions); + layout.Children.Add(picker); + + Content = layout; + + } + } +} \ No newline at end of file diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems index af0991ecb0b..ff485b8a1ab 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems @@ -1814,6 +1814,7 @@ + diff --git a/Xamarin.Forms.Platform.iOS/Renderers/PickerRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/PickerRenderer.cs index 6aeab0e95bc..57e34b9ea44 100644 --- a/Xamarin.Forms.Platform.iOS/Renderers/PickerRenderer.cs +++ b/Xamarin.Forms.Platform.iOS/Renderers/PickerRenderer.cs @@ -179,6 +179,7 @@ void OnStarted(object sender, EventArgs eventArgs) void RowsCollectionChanged(object sender, EventArgs e) { + _picker.ReloadAllComponents(); UpdatePicker(); } @@ -241,7 +242,6 @@ void UpdatePicker() var oldText = Control.Text; Control.Text = selectedIndex == -1 || items == null || selectedIndex >= items.Count ? "" : items[selectedIndex]; UpdatePickerNativeSize(oldText); - _picker.ReloadAllComponents(); if (items == null || items.Count == 0) return;