Skip to content

Commit f1df1a9

Browse files
[iOS, Mac] Fix for Picker title is not displayed again when SelectedIndex is set to -1 (#30486)
* Fix for Picker title not restoring after deselection on iOS * Modified test * Modified AutomationID * Modified testcase * [tests] Add windows and mac snapshots --------- Co-authored-by: Rui Marinho <me@ruimarinho.net>
1 parent ac0addb commit f1df1a9

File tree

7 files changed

+59
-0
lines changed

7 files changed

+59
-0
lines changed
25 KB
Loading
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
namespace Maui.Controls.Sample.Issues;
2+
3+
[Issue(IssueTracker.Github, 30463, "Picker title is not displayed again", PlatformAffected.iOS)]
4+
public class Issue30463 : ContentPage
5+
{
6+
public Issue30463()
7+
{
8+
VerticalStackLayout stackLayout = new VerticalStackLayout
9+
{
10+
Padding = 20,
11+
Spacing = 10
12+
};
13+
14+
Picker picker = new Picker
15+
{
16+
AutomationId = "RegainingPickerTitle",
17+
Title = "Select an item",
18+
ItemsSource = new List<string> { "Item 1", "Item 2", "Item 3" },
19+
SelectedIndex = 1
20+
};
21+
22+
Button button = new Button
23+
{
24+
AutomationId = "ToggleSelectedIndexBtn",
25+
Text = "Click to change selected index to -1"
26+
};
27+
button.Clicked += (sender, e) =>
28+
{
29+
picker.SelectedIndex = -1;
30+
};
31+
32+
stackLayout.Children.Add(picker);
33+
stackLayout.Children.Add(button);
34+
Content = stackLayout;
35+
}
36+
}
37+
10.3 KB
Loading
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using NUnit.Framework;
2+
using UITest.Appium;
3+
using UITest.Core;
4+
5+
namespace Microsoft.Maui.TestCases.Tests.Issues;
6+
7+
public class Issue30463 : _IssuesUITest
8+
{
9+
public Issue30463(TestDevice device) : base(device) { }
10+
11+
public override string Issue => "Picker title is not displayed again";
12+
13+
[Test]
14+
[Category(UITestCategories.Picker)]
15+
public void PickerShouldRegainTitle()
16+
{
17+
App.WaitForElement("ToggleSelectedIndexBtn");
18+
App.Tap("ToggleSelectedIndexBtn");
19+
VerifyScreenshot();
20+
}
21+
}
8.47 KB
Loading
26.1 KB
Loading

src/Core/src/Platform/iOS/PickerExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ internal static void UpdatePicker(this MauiPicker platformPicker, IPicker picker
3838
}
3939
else
4040
{
41+
platformPicker.Text = null;
4142
platformPicker.UpdatePickerTitle(picker);
4243
}
4344

0 commit comments

Comments
 (0)