Skip to content

Commit 89a7c6b

Browse files
authored
Revert "[Android, iOS] Dynamically setting SearchHandler Query property does not update text in the search box (#28400)" (#30222)
* Revert "[Android, iOS] Dynamically setting SearchHandler Query property does not update text in the search box (#28400)" This reverts commit 559da79. # Conflicts: # src/Controls/src/Core/Compatibility/Handlers/Shell/Android/SearchHandlerAppearanceTracker.cs # src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/SearchHandlerAppearanceTracker.cs # src/Controls/tests/TestCases.HostApp/Issues/Issue14497.cs # src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue14497.cs * Revert "[Android & iOS] Fix for SearchHandler Character Spacing Property (#29497)" This reverts commit 9827339. # Conflicts: # src/Controls/src/Core/Compatibility/Handlers/Shell/Android/SearchHandlerAppearanceTracker.cs # src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/SearchHandlerAppearanceTracker.cs # src/Controls/tests/TestCases.HostApp/Issues/Issue29492.cs # src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue29492.cs * - remove character spacing
1 parent cf37815 commit 89a7c6b

File tree

5 files changed

+2
-154
lines changed

5 files changed

+2
-154
lines changed

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

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ public SearchHandlerAppearanceTracker(IShellSearchView searchView, IShellContext
3838
UpdateHorizontalTextAlignment();
3939
UpdateVerticalTextAlignment();
4040
UpdateInputType();
41-
UpdateCharacterSpacing();
4241
}
4342

4443
protected virtual void SearchHandlerPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
@@ -87,39 +86,6 @@ protected virtual void SearchHandlerPropertyChanged(object sender, System.Compon
8786
{
8887
UpdateAutomationId();
8988
}
90-
else if (e.Is(SearchHandler.QueryProperty))
91-
{
92-
UpdateText();
93-
}
94-
else if (e.Is(SearchHandler.CharacterSpacingProperty))
95-
{
96-
UpdateCharacterSpacing();
97-
}
98-
}
99-
void UpdateCharacterSpacing()
100-
{
101-
if (_editText is not null)
102-
{
103-
_editText.LetterSpacing = _searchHandler.CharacterSpacing.ToEm();
104-
}
105-
}
106-
107-
void UpdateText()
108-
{
109-
int cursorPosition = _editText.SelectionStart;
110-
bool selectionExists = _editText.HasSelection;
111-
112-
_editText.Text = _searchHandler.Query ?? string.Empty;
113-
114-
UpdateTextTransform();
115-
116-
// If we had a selection, place the cursor at the end of text
117-
// Otherwise try to maintain the cursor at its previous position
118-
int textLength = _editText.Text?.Length ?? 0;
119-
int newPosition = selectionExists ? textLength : Math.Min(cursorPosition, textLength);
120-
121-
// Prevents the cursor from resetting to position zero when text is set programmatically
122-
_editText.SetSelection(newPosition);
12389
}
12490

12591
void EditTextFocusChange(object s, AView.FocusChangeEventArgs args)

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

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -114,45 +114,7 @@ void SearchHandlerPropertyChanged(object sender, System.ComponentModel.PropertyC
114114
else if (e.Is(SearchHandler.VerticalTextAlignmentProperty))
115115
{
116116
UpdateSearchBarVerticalTextAlignment(_uiSearchBar.FindDescendantView<UITextField>());
117-
}
118-
else if (e.Is(SearchHandler.QueryProperty))
119-
{
120-
UpdateText(_uiSearchBar.FindDescendantView<UITextField>());
121-
}
122-
else if (e.Is(SearchHandler.CharacterSpacingProperty))
123-
{
124-
UpdateCharacterSpacing(_uiSearchBar.FindDescendantView<UITextField>());
125-
}
126-
}
127-
128-
void UpdateText(UITextField uiTextField)
129-
{
130-
if (uiTextField is null)
131-
return;
132-
133-
uiTextField.Text = _searchHandler.Query;
134-
UpdateTextTransform(uiTextField);
135-
UpdateCharacterSpacing(uiTextField);
136-
}
137-
138-
void UpdateCharacterSpacing(UITextField textField)
139-
{
140-
if (textField is null)
141-
{
142-
return;
143-
}
144-
145-
var attributedText = textField.AttributedText?.WithCharacterSpacing(_searchHandler.CharacterSpacing);
146-
if (attributedText is not null)
147-
{
148-
textField.AttributedText = attributedText;
149-
}
150-
151-
var placeholderAttributedText = textField.AttributedPlaceholder?.WithCharacterSpacing(_searchHandler.CharacterSpacing);
152-
if (placeholderAttributedText is not null)
153-
{
154-
textField.AttributedPlaceholder = placeholderAttributedText;
155-
}
117+
}
156118
}
157119

158120
void GetDefaultSearchBarColors(UISearchBar searchBar)

src/Controls/tests/TestCases.HostApp/Issues/Issue14497.cs

Lines changed: 0 additions & 57 deletions
This file was deleted.

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue14497.cs

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue29492.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if TEST_FAILS_ON_WINDOWS // Windows Character Spacing Issue Link - https://github.com/dotnet/maui/issues/29493
1+
#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
22
using NUnit.Framework;
33
using UITest.Appium;
44
using UITest.Core;

0 commit comments

Comments
 (0)