-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[iOS, Mac, Windows] Fixed CharacterSpacing for SearchBar text and placeholder text #30407
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
base: main
Are you sure you want to change the base?
Conversation
Hey there @@Dhivya-SF4094! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
/azp run MAUI-UITests-public |
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The added snapshots contains the cursor. Because is blinking, the test could randomly fail. Could you update the test to remove the cursor?
Use:
public static readonly BindableProperty IsCursorVisibleProperty = |
@jsuarezruiz Updated the test sample to set IsCursorVisible to false using the UITestSearchBar.IsCursorVisibleProperty |
/azp run MAUI-UITests-public |
Azure Pipelines successfully started running 1 pipeline(s). |
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Issue Detail
The CharacterSpacing property in SearchBar behaves inconsistently across platforms:
Root Cause
iOS: The CharacterSpacing logic for SearchBar is defined in UpdateCharacterSpacing() in TextFieldExtensions.cs, shared across Entry, Editor, and SearchBar.
For Entry and Editor, it's triggered via MapFormatting(), which is called from MapText() (e.g., in Entry.iOS), ensuring spacing is applied on load and text change.
For SearchBar, MapFormatting() was not invoked, so CharacterSpacing was never applied to either the search text or placeholder.
Windows - The CharacterSpacing property of the SearchBar is applied only to the search text via the AutoSuggestBox.CharacterSpacing property. However, the placeholder text is rendered by a separate internal TextBlock that does not inherit this spacing, resulting in default character spacing for the placeholder.
Description of Change
iOS: The fix involves explicitly calling MapFormatting() within the MapText() method of SearchBar.iOS.
Windows: The fix explicitly locates the TextBlock rendering the placeholder using GetFirstDescendant() and applies the same CharacterSpacing to it within the OnLoaded lifecycle of the AutoSuggestBox. This ensures that both search text and placeholder text reflect the correct spacing consistently.
Validated the behaviour in the following platforms
Issues Fixed:
Fixes #30366
Screenshots