Skip to content

Commit 20be089

Browse files
NanthiniMahalingamPureWeen
authored andcommitted
Fixed Picker Items are not Displaying on macOS platform (#27535)
* Fixed the picker view items source does not display on mac platform * Added the test case * Added the output images. * Fixed the picker view items source does not display on mac platform * Added the test case * Added the output images. * Create ShouldDisplayPickerItemsWhenOpeningPicker.png Added the output image on windows platform * Ignore the test case on catalyst platform * Added the test case for mac platform * Added the macOS output image * Added the comment line for fix.
1 parent 85bde74 commit 20be089

File tree

7 files changed

+42
-2
lines changed

7 files changed

+42
-2
lines changed
21.4 KB
Loading
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace Controls.TestCases.HostApp.Issues;
2+
3+
[Issue(IssueTracker.Github, 27474, "Picker view items are not displayed when setting the title on the picker control", PlatformAffected.macOS)]
4+
public class Issue27474 : ContentPage
5+
{
6+
public Issue27474()
7+
{
8+
Content = new Picker
9+
{
10+
AutomationId = "Picker",
11+
ItemsSource = new List<string> { "Badminton", "Football", "Cricket", "Chess", "Swimming" },
12+
Title = "Select sports",
13+
};
14+
}
15+
}
24.4 KB
Loading
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using NUnit.Framework;
2+
using UITest.Appium;
3+
using UITest.Core;
4+
5+
namespace Microsoft.Maui.TestCases.Tests.Issues
6+
{
7+
public class Issue27474 : _IssuesUITest
8+
{
9+
public Issue27474(TestDevice testDevice) : base(testDevice)
10+
{
11+
}
12+
13+
public override string Issue => "Picker view items are not displayed when setting the title on the picker control";
14+
15+
[Test]
16+
[Category(UITestCategories.Picker)]
17+
public void ShouldDisplayPickerItemsWhenOpeningPicker()
18+
{
19+
App.WaitForElement("Picker");
20+
App.Click("Picker");
21+
VerifyScreenshot();
22+
}
23+
}
24+
}
9.04 KB
Loading
68.7 KB
Loading

src/Core/src/Handlers/Picker/PickerHandler.iOS.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ void DisplayAlert(MauiPicker uITextField)
4949
var pickerView = new UIPickerView(frame);
5050
pickerView.Model = new PickerSource(this);
5151
pickerView?.ReloadAllComponents();
52-
53-
var pickerController = UIAlertController.Create(VirtualView.Title, "", UIAlertControllerStyle.ActionSheet);
52+
// The UIPickerView is displayed as a subview of the UIAlertController when an empty string is provided as the title, instead of using the VirtualView title.
53+
// This behavior deviates from the expected native macOS behavior.
54+
var pickerController = UIAlertController.Create("", "", UIAlertControllerStyle.ActionSheet);
5455

5556
// needs translation
5657
pickerController.AddAction(UIAlertAction.Create("Done",

0 commit comments

Comments
 (0)