Skip to content

Commit 7127454

Browse files
Tamilarasan-ParanthamanPureWeen
authored andcommitted
[Android] Fix for SearchHandler Placeholder did not update when changed at runtime (#28636)
* Placeholder issue fix * Added Android snapshot * Added Mac and Windows snapshots
1 parent 589fd52 commit 7127454

File tree

7 files changed

+81
-0
lines changed

7 files changed

+81
-0
lines changed

src/Controls/src/Core/Compatibility/Handlers/Shell/Android/SearchHandlerAppearanceTracker.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ protected virtual void SearchHandlerPropertyChanged(object sender, System.Compon
5454
{
5555
UpdateTextTransform();
5656
}
57+
else if (e.Is(SearchHandler.PlaceholderProperty))
58+
{
59+
UpdatePlaceholder();
60+
}
5761
else if (e.Is(SearchHandler.PlaceholderColorProperty))
5862
{
5963
UpdatePlaceholderColor();
@@ -137,6 +141,11 @@ void UpdateFont()
137141
_editText.SetTextSize(ComplexUnitType.Sp, (float)_searchHandler.FontSize);
138142
}
139143

144+
void UpdatePlaceholder()
145+
{
146+
_editText.Hint = _searchHandler.Placeholder;
147+
}
148+
140149
void UpdatePlaceholderColor()
141150
{
142151
_editText.UpdatePlaceholderColor(_searchHandler.PlaceholderColor);
27.8 KB
Loading
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
namespace Maui.Controls.Sample.Issues;
2+
3+
[Issue(IssueTracker.Github, 28634, "[Android] SearchHandler Placeholder Text", PlatformAffected.Android)]
4+
public class Issue28634 : TestShell
5+
{
6+
7+
protected override void Init()
8+
{
9+
this.FlyoutBehavior = FlyoutBehavior.Flyout;
10+
11+
var shellContent = new ShellContent
12+
{
13+
Title = "Home",
14+
Route = "MainPage",
15+
Content = new Issue28634ContentPage() { Title = "Home" }
16+
};
17+
18+
Items.Add(shellContent);
19+
20+
}
21+
class Issue28634ContentPage : ContentPage
22+
{
23+
public Issue28634ContentPage()
24+
{
25+
26+
var searchHandler = new SearchHandler
27+
{
28+
Placeholder = "Type a fruit name to search",
29+
PlaceholderColor = Colors.Red,
30+
};
31+
32+
var button = new Button
33+
{
34+
Text = "Change SearchHandler Placeholder",
35+
AutomationId = "button",
36+
HorizontalOptions = LayoutOptions.Center,
37+
VerticalOptions = LayoutOptions.Center,
38+
};
39+
button.Clicked += (s, e) =>
40+
{
41+
searchHandler.Placeholder = "Type a vegetable name to search";
42+
};
43+
44+
Shell.SetSearchHandler(this, searchHandler);
45+
46+
Content = button;
47+
}
48+
}
49+
}
12.7 KB
Loading
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using NUnit.Framework;
2+
using UITest.Appium;
3+
using UITest.Core;
4+
5+
namespace Microsoft.Maui.TestCases.Tests.Issues;
6+
7+
public class Issue28634 : _IssuesUITest
8+
{
9+
public override string Issue => "[Android] SearchHandler Placeholder Text";
10+
11+
public Issue28634(TestDevice device)
12+
: base(device)
13+
{ }
14+
15+
[Test]
16+
[Category(UITestCategories.Shell)]
17+
public void VerifySearchHandlerPlaceholderText()
18+
{
19+
App.WaitForElement("button");
20+
App.Tap("button");
21+
VerifyScreenshot();
22+
}
23+
}
10.3 KB
Loading
38.3 KB
Loading

0 commit comments

Comments
 (0)