-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fixed the Picker didn't dismiss it when tapping outside on iOS and MacCatalyst platform. #30067
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kubaflo
merged 9 commits into
dotnet:inflight/current
from
KarthikRajaKalaimani:fix-19168
Mar 30, 2026
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
91eb0f6
Test case added
KarthikRajaKalaimani 5b630d6
Test case added
KarthikRajaKalaimani 36042ea
Modified the code
KarthikRajaKalaimani b2c4117
Snapshot added for mac and winui
KarthikRajaKalaimani b278db3
Test case modified for android
KarthikRajaKalaimani 746aa85
Implemented fix again
KarthikRajaKalaimani eace95a
Copilot review concerns addressed
KarthikRajaKalaimani d4cf528
Fixed the error
KarthikRajaKalaimani 5510680
Fix improved
KarthikRajaKalaimani File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
Binary file added
BIN
+7.69 KB
...Cases.Android.Tests/snapshots/android/PickerShouldDismissWhenClickOnOutside.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| namespace Maui.Controls.Sample.Issues; | ||
|
|
||
| [Issue(IssueTracker.Github, 19168, "iOS Picker dismiss does not work when clicking outside of the Picker", PlatformAffected.iOS | PlatformAffected.macOS)] | ||
| public class Issue19168 : ContentPage | ||
| { | ||
| Picker picker; | ||
| public Issue19168() | ||
| { | ||
| picker = new Picker | ||
| { | ||
| ItemsSource = new List<string> | ||
| { | ||
| "Baboon", | ||
| "Capuchin Monkey", | ||
| "Blue Monkey", | ||
| "Squirrel Monkey", | ||
| "Golden Lion Tamarin", | ||
| "Howler Monkey", | ||
| "Japanese Macaque" | ||
| }, | ||
| AutomationId = "Picker" | ||
| }; | ||
|
|
||
| var counterBtn = new Button | ||
| { | ||
| Text = "Click me", | ||
| AutomationId = "Button", | ||
| VerticalOptions = LayoutOptions.End, | ||
| HorizontalOptions = LayoutOptions.Fill | ||
| }; | ||
| Content = new ScrollView | ||
| { | ||
| Content = new VerticalStackLayout | ||
| { | ||
| Padding = new Thickness(30, 0), | ||
| Spacing = 25, | ||
| Children = | ||
| { | ||
| picker, | ||
| counterBtn, | ||
| } | ||
| } | ||
| }; | ||
| } | ||
| } |
Binary file added
BIN
+5.86 KB
...sts/TestCases.Mac.Tests/snapshots/mac/PickerShouldDismissWhenClickOnOutside.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions
32
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue19168.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
|
|
||
| public class Issue19168 : _IssuesUITest | ||
| { | ||
| public Issue19168(TestDevice testDevice) : base(testDevice) | ||
| { | ||
| } | ||
| public override string Issue => "iOS Picker dismiss does not work when clicking outside of the Picker"; | ||
|
|
||
| [Test] | ||
| [Category(UITestCategories.Picker)] | ||
| public void PickerShouldDismissWhenClickOnOutside() | ||
| { | ||
| App.WaitForElement("Picker"); | ||
| App.Tap("Picker"); | ||
| #if MACCATALYST | ||
| App.TapCoordinates(600, 200); | ||
| App.WaitForElement("Button"); | ||
| #elif ANDROID | ||
| App.TapCoordinates(0, 100); | ||
| #elif WINDOWS | ||
| App.TapCoordinates(60, 600); | ||
| #elif IOS | ||
| App.Tap("Button"); | ||
| #endif | ||
| VerifyScreenshot(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| } | ||
| } | ||
Binary file added
BIN
+3.71 KB
...stCases.WinUI.Tests/snapshots/windows/PickerShouldDismissWhenClickOnOutside.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.3 KB
...sts/TestCases.iOS.Tests/snapshots/ios/PickerShouldDismissWhenClickOnOutside.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Platform-specific conditional compilation violates the UI testing guidelines. According to the coding guidelines, tests should run on all applicable platforms by default unless there's a specific technical limitation. This test uses different approaches for each platform (coordinates vs button tap), which makes the test inconsistent across platforms. Consider implementing a unified approach that works across all platforms, or if platform-specific behavior is truly necessary, document why each platform requires different testing logic.