diff --git a/src/Controls/src/Core/Compatibility/Handlers/Shell/Android/SearchHandlerAppearanceTracker.cs b/src/Controls/src/Core/Compatibility/Handlers/Shell/Android/SearchHandlerAppearanceTracker.cs index 6b21640b0ca2..7663eb82493e 100644 --- a/src/Controls/src/Core/Compatibility/Handlers/Shell/Android/SearchHandlerAppearanceTracker.cs +++ b/src/Controls/src/Core/Compatibility/Handlers/Shell/Android/SearchHandlerAppearanceTracker.cs @@ -54,6 +54,10 @@ protected virtual void SearchHandlerPropertyChanged(object sender, System.Compon { UpdateTextTransform(); } + else if (e.Is(SearchHandler.PlaceholderProperty)) + { + UpdatePlaceholder(); + } else if (e.Is(SearchHandler.PlaceholderColorProperty)) { UpdatePlaceholderColor(); @@ -115,6 +119,11 @@ void UpdateFont() _editText.SetTextSize(ComplexUnitType.Sp, (float)_searchHandler.FontSize); } + void UpdatePlaceholder() + { + _editText.Hint = _searchHandler.Placeholder; + } + void UpdatePlaceholderColor() { _editText.UpdatePlaceholderColor(_searchHandler.PlaceholderColor); diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/VerifySearchHandlerPlaceholderText.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/VerifySearchHandlerPlaceholderText.png new file mode 100644 index 000000000000..3065fce58707 Binary files /dev/null and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/VerifySearchHandlerPlaceholderText.png differ diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue28634.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue28634.cs new file mode 100644 index 000000000000..3397fa26a9bf --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue28634.cs @@ -0,0 +1,49 @@ +namespace Maui.Controls.Sample.Issues; + +[Issue(IssueTracker.Github, 28634, "[Android] SearchHandler Placeholder Text", PlatformAffected.Android)] +public class Issue28634 : TestShell +{ + + protected override void Init() + { + this.FlyoutBehavior = FlyoutBehavior.Flyout; + + var shellContent = new ShellContent + { + Title = "Home", + Route = "MainPage", + Content = new Issue28634ContentPage() { Title = "Home" } + }; + + Items.Add(shellContent); + + } + class Issue28634ContentPage : ContentPage + { + public Issue28634ContentPage() + { + + var searchHandler = new SearchHandler + { + Placeholder = "Type a fruit name to search", + PlaceholderColor = Colors.Red, + }; + + var button = new Button + { + Text = "Change SearchHandler Placeholder", + AutomationId = "button", + HorizontalOptions = LayoutOptions.Center, + VerticalOptions = LayoutOptions.Center, + }; + button.Clicked += (s, e) => + { + searchHandler.Placeholder = "Type a vegetable name to search"; + }; + + Shell.SetSearchHandler(this, searchHandler); + + Content = button; + } + } +} \ No newline at end of file diff --git a/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/VerifySearchHandlerPlaceholderText.png b/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/VerifySearchHandlerPlaceholderText.png new file mode 100644 index 000000000000..b148ed245347 Binary files /dev/null and b/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/VerifySearchHandlerPlaceholderText.png differ diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue28634.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue28634.cs new file mode 100644 index 000000000000..ed13a444331f --- /dev/null +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue28634.cs @@ -0,0 +1,23 @@ +using NUnit.Framework; +using UITest.Appium; +using UITest.Core; + +namespace Microsoft.Maui.TestCases.Tests.Issues; + +public class Issue28634 : _IssuesUITest +{ + public override string Issue => "[Android] SearchHandler Placeholder Text"; + + public Issue28634(TestDevice device) + : base(device) + { } + + [Test] + [Category(UITestCategories.Shell)] + public void VerifySearchHandlerPlaceholderText() + { + App.WaitForElement("button"); + App.Tap("button"); + VerifyScreenshot(); + } +} diff --git a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifySearchHandlerPlaceholderText.png b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifySearchHandlerPlaceholderText.png new file mode 100644 index 000000000000..8a28a5837faa Binary files /dev/null and b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifySearchHandlerPlaceholderText.png differ diff --git a/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/VerifySearchHandlerPlaceholderText.png b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/VerifySearchHandlerPlaceholderText.png new file mode 100644 index 000000000000..3de7d7a381ec Binary files /dev/null and b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/VerifySearchHandlerPlaceholderText.png differ