diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue32984.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue32984.cs new file mode 100644 index 000000000000..f9e9e1f91b9e --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue32984.cs @@ -0,0 +1,35 @@ +namespace Maui.Controls.Sample.Issues; + +[Issue(IssueTracker.Github, "32984", "Picker on resize not working on Windows", PlatformAffected.UWP)] +public class Issue32984 : ContentPage +{ + public Issue32984() + { + VerticalStackLayout layout = new VerticalStackLayout + { + WidthRequest = 600 + }; + + Picker issue32984Picker = new Picker + { + AutomationId= "issue32984Picker", + Title = "Select an item", + HorizontalOptions = LayoutOptions.Fill, + ItemsSource = new List { "Item1", "Item2", "Item3"} + }; + + Button button = new Button + { + AutomationId= "issue32984Button", + Text = "Click me", + HorizontalOptions = LayoutOptions.Fill + }; + + button.Clicked += (s, e) => { layout.WidthRequest = 200; }; + + layout.Children.Add(issue32984Picker); + layout.Children.Add(button); + + Content = layout; + } +} \ No newline at end of file diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue32984.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue32984.cs new file mode 100644 index 000000000000..7e5e6aa69af1 --- /dev/null +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue32984.cs @@ -0,0 +1,35 @@ +using NUnit.Framework; +using UITest.Appium; +using UITest.Core; + +namespace Microsoft.Maui.TestCases.Tests.Issues; + +public class Issue32984 : _IssuesUITest +{ + public Issue32984(TestDevice device) + : base(device) + { + } + + public override string Issue => "Picker on resize not working on Windows"; + + [Test] + [Category(UITestCategories.Picker)] + public void Issue32984PickerShouldResize() + { + App.WaitForElement("issue32984Button"); + App.Tap("issue32984Picker"); +#if ANDROID + App.WaitForElement("Cancel"); + App.Tap("Cancel"); +#elif IOS || MACCATALYST + App.WaitForElement("Done"); + App.Tap("Done"); +#elif WINDOWS + App.TapCoordinates(10, 10); +#endif + App.Tap("issue32984Button"); + App.Tap("issue32984Picker"); + VerifyScreenshot(); + } +} \ No newline at end of file diff --git a/src/Core/src/Handlers/Picker/PickerHandler.Windows.cs b/src/Core/src/Handlers/Picker/PickerHandler.Windows.cs index 7275ebf2c20a..ede369bf75aa 100644 --- a/src/Core/src/Handlers/Picker/PickerHandler.Windows.cs +++ b/src/Core/src/Handlers/Picker/PickerHandler.Windows.cs @@ -145,6 +145,12 @@ void OnMauiComboBoxDropDownClosed(object? sender, object e) if (VirtualView is null) return; + if (sender is ComboBox comboBox && comboBox.MinWidth > 0) + { + //Reset the MinWidth to allow ComboBox to resize when the parent's size changes + comboBox.MinWidth = 0; + } + VirtualView.IsOpen = false; } }