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 ef60072b7a95..7663eb82493e 100644 --- a/src/Controls/src/Core/Compatibility/Handlers/Shell/Android/SearchHandlerAppearanceTracker.cs +++ b/src/Controls/src/Core/Compatibility/Handlers/Shell/Android/SearchHandlerAppearanceTracker.cs @@ -38,7 +38,6 @@ public SearchHandlerAppearanceTracker(IShellSearchView searchView, IShellContext UpdateHorizontalTextAlignment(); UpdateVerticalTextAlignment(); UpdateInputType(); - UpdateCharacterSpacing(); } protected virtual void SearchHandlerPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) @@ -87,39 +86,6 @@ protected virtual void SearchHandlerPropertyChanged(object sender, System.Compon { UpdateAutomationId(); } - else if (e.Is(SearchHandler.QueryProperty)) - { - UpdateText(); - } - else if (e.Is(SearchHandler.CharacterSpacingProperty)) - { - UpdateCharacterSpacing(); - } - } - void UpdateCharacterSpacing() - { - if (_editText is not null) - { - _editText.LetterSpacing = _searchHandler.CharacterSpacing.ToEm(); - } - } - - void UpdateText() - { - int cursorPosition = _editText.SelectionStart; - bool selectionExists = _editText.HasSelection; - - _editText.Text = _searchHandler.Query ?? string.Empty; - - UpdateTextTransform(); - - // If we had a selection, place the cursor at the end of text - // Otherwise try to maintain the cursor at its previous position - int textLength = _editText.Text?.Length ?? 0; - int newPosition = selectionExists ? textLength : Math.Min(cursorPosition, textLength); - - // Prevents the cursor from resetting to position zero when text is set programmatically - _editText.SetSelection(newPosition); } void EditTextFocusChange(object s, AView.FocusChangeEventArgs args) diff --git a/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/SearchHandlerAppearanceTracker.cs b/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/SearchHandlerAppearanceTracker.cs index c1df89d91990..c155925e8bea 100644 --- a/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/SearchHandlerAppearanceTracker.cs +++ b/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/SearchHandlerAppearanceTracker.cs @@ -114,45 +114,7 @@ void SearchHandlerPropertyChanged(object sender, System.ComponentModel.PropertyC else if (e.Is(SearchHandler.VerticalTextAlignmentProperty)) { UpdateSearchBarVerticalTextAlignment(_uiSearchBar.FindDescendantView()); - } - else if (e.Is(SearchHandler.QueryProperty)) - { - UpdateText(_uiSearchBar.FindDescendantView()); - } - else if (e.Is(SearchHandler.CharacterSpacingProperty)) - { - UpdateCharacterSpacing(_uiSearchBar.FindDescendantView()); - } - } - - void UpdateText(UITextField uiTextField) - { - if (uiTextField is null) - return; - - uiTextField.Text = _searchHandler.Query; - UpdateTextTransform(uiTextField); - UpdateCharacterSpacing(uiTextField); - } - - void UpdateCharacterSpacing(UITextField textField) - { - if (textField is null) - { - return; - } - - var attributedText = textField.AttributedText?.WithCharacterSpacing(_searchHandler.CharacterSpacing); - if (attributedText is not null) - { - textField.AttributedText = attributedText; - } - - var placeholderAttributedText = textField.AttributedPlaceholder?.WithCharacterSpacing(_searchHandler.CharacterSpacing); - if (placeholderAttributedText is not null) - { - textField.AttributedPlaceholder = placeholderAttributedText; - } + } } void GetDefaultSearchBarColors(UISearchBar searchBar) diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue14497.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue14497.cs deleted file mode 100644 index a3babe67d6ab..000000000000 --- a/src/Controls/tests/TestCases.HostApp/Issues/Issue14497.cs +++ /dev/null @@ -1,57 +0,0 @@ -namespace Maui.Controls.Sample.Issues; - -[Issue(IssueTracker.Github, 14497, "Dynamically setting SearchHandler Query property does not update text in the search box", PlatformAffected.Android | PlatformAffected.iOS)] -public class Issue14497 : Shell -{ - public Issue14497() - { - ShellContent shellContent = new ShellContent - { - Title = "Home", - ContentTemplate = new DataTemplate(typeof(Issue14497Page)), - Route = "MainPage" - }; - - Items.Add(shellContent); - } -} - -public class Issue14497Page : ContentPage -{ - Issue14497CustomSearchHandler _searchHandler; - public Issue14497Page() - { - _searchHandler = new Issue14497CustomSearchHandler(); - - Button button = new Button - { - Text = "Change Search Text", - AutomationId = "ChangeSearchText" - }; - - button.Clicked += (s, e) => _searchHandler.SetQuery("Hello World"); - - VerticalStackLayout stackLayout = new VerticalStackLayout - { - Children = { button } - }; - - Content = stackLayout; - Shell.SetSearchHandler(this, _searchHandler); - } -} - -public class Issue14497CustomSearchHandler : SearchHandler -{ - public Issue14497CustomSearchHandler() - { - Placeholder = "Search..."; - ShowsResults = false; - } - - public void SetQuery(string searchText) - { - Query = searchText; - } - -} \ No newline at end of file diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue14497.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue14497.cs deleted file mode 100644 index baf470132526..000000000000 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue14497.cs +++ /dev/null @@ -1,23 +0,0 @@ -using NUnit.Framework; -using UITest.Appium; -using UITest.Core; - -namespace Microsoft.Maui.TestCases.Tests.Issues; - -public class Issue14497 : _IssuesUITest -{ - public Issue14497(TestDevice device) : base(device) { } - - public override string Issue => "Dynamically setting SearchHandler Query property does not update text in the search box"; - const string ChangeSearchText = "ChangeSearchText"; - - [Test] - [Category(UITestCategories.Shell)] - public void DynamicallyQueryNotUpdating() - { - App.WaitForElement(ChangeSearchText); - App.Tap(ChangeSearchText); - var searchHandlerString = App.GetShellSearchHandler().GetText(); - Assert.That(searchHandlerString, Is.EqualTo("Hello World")); - } -} \ No newline at end of file diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue29492.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue29492.cs index a603bf88062e..36adde46ba62 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue29492.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue29492.cs @@ -1,4 +1,4 @@ -#if TEST_FAILS_ON_WINDOWS // Windows Character Spacing Issue Link - https://github.com/dotnet/maui/issues/29493 +#if TEST_FAILS_ON_WINDOWS && TEST_FAILS_ON_IOS && TEST_FAILS_ON_ANDROID // Windows Character Spacing Issue Link - https://github.com/dotnet/maui/issues/29493 using NUnit.Framework; using UITest.Appium; using UITest.Core;