Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue27474.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace Controls.TestCases.HostApp.Issues;

[Issue(IssueTracker.Github, 27474, "Picker view items are not displayed when setting the title on the picker control", PlatformAffected.macOS)]
public class Issue27474 : ContentPage
{
public Issue27474()
{
Content = new Picker
{
AutomationId = "Picker",
ItemsSource = new List<string> { "Badminton", "Football", "Cricket", "Chess", "Swimming" },
Title = "Select sports",
};
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues
{
public class Issue27474 : _IssuesUITest
{
public Issue27474(TestDevice testDevice) : base(testDevice)
{
}

public override string Issue => "Picker view items are not displayed when setting the title on the picker control";

[Test]
[Category(UITestCategories.Picker)]
public void ShouldDisplayPickerItemsWhenOpeningPicker()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test is failing on Mac because the reference snapshot is pending. Already available in the latest build.
image
Could you commit it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test is failing on Mac because the reference snapshot is pending. Already available in the latest build. image Could you commit it?

I've committed the macOS output image. Could you please verify it?

{
App.WaitForElement("Picker");
App.Click("Picker");
VerifyScreenshot();
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions src/Core/src/Handlers/Picker/PickerHandler.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ void DisplayAlert(MauiPicker uITextField)
var pickerView = new UIPickerView(frame);
pickerView.Model = new PickerSource(this);
pickerView?.ReloadAllComponents();

var pickerController = UIAlertController.Create(VirtualView.Title, "", UIAlertControllerStyle.ActionSheet);
// 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.
// This behavior deviates from the expected native macOS behavior.
var pickerController = UIAlertController.Create("", "", UIAlertControllerStyle.ActionSheet);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't look like a proper fix, but a hack to get it working

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @StephaneDelcroix ,

  • On the macOS native platform, when setting the title in a UIAlertController, only the title is displayed, rather than any subview added to the UIAlertController.
  • However, when setting an empty string as the title in UIAlertController, the added subview is displayed as expected.
  • Similarly, in the .NET MAUI macOS platform, a UIAlertController displays a UIPickerView added as a subview. When setting the title as an empty string, the UIPickerView subview behaves like its native macOS.
image image


// needs translation
pickerController.AddAction(UIAlertAction.Create("Done",
Expand Down
Loading