-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Android] SearchHandler - added focus/unfocus support #24852
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| <?xml version="1.0" encoding="utf-8" ?> | ||
| <Shell xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
| x:Class="Maui.Controls.Sample.Issues.Issue24670"> | ||
| <ShellContent | ||
| Title="Home" | ||
| Route="MainPage"> | ||
| <ContentPage> | ||
| <Shell.SearchHandler> | ||
| <SearchHandler | ||
| x:Name="searchHandler" | ||
| AutomationId="searchHandler" | ||
| Placeholder="searchHandler" | ||
| SearchBoxVisibility="Expanded" | ||
|
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. I wanted to add AutomationId("searchHandler") and click this in the UI test, but Appium couldn't find it :/ |
||
| Focused="SearchHandler_Focused" | ||
| Unfocused="SearchHandler_Unfocused"/> | ||
| </Shell.SearchHandler> | ||
|
|
||
| <StackLayout> | ||
| <Entry AutomationId="entry"/> | ||
| <Label x:Name="focusedLabel" | ||
| AutomationId="focusedLabel" | ||
| Text="Focused: False"/> | ||
| <Label x:Name="unfocusedLabel" | ||
| AutomationId="unfocusedLabel" | ||
| Text="Unfocused: False"/> | ||
| </StackLayout> | ||
| </ContentPage> | ||
| </ShellContent> | ||
| </Shell> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| namespace Maui.Controls.Sample.Issues | ||
| { | ||
| [XamlCompilation(XamlCompilationOptions.Compile)] | ||
| [Issue(IssueTracker.Github, "24670", "SearchHandler.Focused event never fires", PlatformAffected.All)] | ||
| public partial class Issue24670 : Shell | ||
| { | ||
| public Issue24670() | ||
| { | ||
| InitializeComponent(); | ||
| } | ||
|
|
||
| private void SearchHandler_Focused(object sender, EventArgs e) | ||
| { | ||
| focusedLabel.Text = "Focused: True"; | ||
| } | ||
|
|
||
| private void SearchHandler_Unfocused(object sender, EventArgs e) | ||
| { | ||
| unfocusedLabel.Text = "Unfocused: True"; | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| #if ANDROID | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues | ||
| { | ||
| public class Issue24670 : _IssuesUITest | ||
| { | ||
| public override string Issue => "SearchHandler.Focused event never fires"; | ||
|
|
||
| public Issue24670(TestDevice testDevice) : base(testDevice) | ||
| { | ||
| } | ||
|
|
||
| [Test] | ||
| [Category(UITestCategories.Shell)] | ||
| [Category(UITestCategories.SearchBar)] | ||
| public void SearchHandlerFocusAndUnfocusEventsShouldWork() | ||
|
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. This test is failing on Android. Maybe need to use |
||
| { | ||
| App.WaitForElement("searchHandler"); | ||
| App.Click("searchHandler"); | ||
|
|
||
| // Click the entry below to trigger the unfocused event | ||
| App.Click("entry"); | ||
|
|
||
| var focusedLabelText = App.WaitForElement("focusedLabel").GetText(); | ||
| var unfocusedLabelText = App.WaitForElement("unfocusedLabel").GetText(); | ||
|
|
||
| Assert.That(focusedLabelText, Is.EqualTo("Focused: True")); | ||
| Assert.That(unfocusedLabelText, Is.EqualTo("Unfocused: True")); | ||
| } | ||
| } | ||
| } | ||
| #endif | ||
Uh oh!
There was an error while loading. Please reload this page.