-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Android] Picker - focus/unfocus events #28122
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
PureWeen
merged 1 commit into
dotnet:inflight/current
from
kubaflo:Picker-Focused/Unfocused-Events-Do-Not-Fire-on-Android-
Apr 16, 2025
Merged
Changes from all commits
Commits
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
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
src/Controls/tests/TestCases.HostApp/Issues/Issue28121.xaml
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,24 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Class="Maui.Controls.Sample.Issues.Issue28121"> | ||
<VerticalStackLayout> | ||
<Picker Focused="Picker_Focused" | ||
Unfocused="Picker_Unfocused" | ||
AutomationId="picker"> | ||
<Picker.ItemsSource> | ||
<x:Array Type="{x:Type x:String}"> | ||
<x:String>Item1</x:String> | ||
<x:String>Item2</x:String> | ||
<x:String>Item3</x:String> | ||
</x:Array> | ||
</Picker.ItemsSource> | ||
</Picker> | ||
<Label x:Name="FocusedLabel" | ||
AutomationId="focusedLabel" | ||
Text="Focused: false"/> | ||
<Label x:Name="UnfocusedLabel" | ||
AutomationId="unfocusedLabel" | ||
Text="Unfocused: false"/> | ||
</VerticalStackLayout> | ||
</ContentPage> |
21 changes: 21 additions & 0 deletions
21
src/Controls/tests/TestCases.HostApp/Issues/Issue28121.xaml.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,21 @@ | ||
namespace Maui.Controls.Sample.Issues; | ||
|
||
[Issue(IssueTracker.Github, 28121, "Picker Focused/Unfocused Events Do Not Fire", PlatformAffected.Android)] | ||
|
||
public partial class Issue28121 : ContentPage | ||
{ | ||
public Issue28121() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
void Picker_Focused(object sender, FocusEventArgs e) | ||
{ | ||
FocusedLabel.Text = "Focused: true"; | ||
} | ||
|
||
void Picker_Unfocused(object sender, FocusEventArgs e) | ||
{ | ||
UnfocusedLabel.Text = "Unfocused: true"; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue28121.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,33 @@ | ||
#if ANDROID | ||
using NUnit.Framework; | ||
using UITest.Appium; | ||
using UITest.Core; | ||
|
||
namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
|
||
public class Issue28121 : _IssuesUITest | ||
{ | ||
|
||
public Issue28121(TestDevice testDevice) : base(testDevice) | ||
{ | ||
} | ||
|
||
public override string Issue => "Picker Focused/Unfocused Events Do Not Fire"; | ||
|
||
[Test] | ||
[Category(UITestCategories.Entry)] | ||
[Category(UITestCategories.Compatibility)] | ||
public void FocusAndUnfocusEventsShouldFire() | ||
{ | ||
App.WaitForElement("picker"); | ||
App.Tap("picker"); | ||
App.WaitForElement("Item1"); | ||
App.Click("Item1"); | ||
var focusedLabelText = App.FindElement("focusedLabel").GetText(); | ||
var unfocusedLabelText = App.FindElement("unfocusedLabel").GetText(); | ||
|
||
Assert.That(focusedLabelText, Is.EqualTo("Focused: true")); | ||
Assert.That(unfocusedLabelText, Is.EqualTo("Unfocused: true")); | ||
} | ||
} | ||
#endif |
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
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.
While the fix is for Android, I think the test could run on all the platforms and verify the same events everywhere. Could we remove the compilation directive?
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.
It won't work because even with such addition
the iOS picker won't close