diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/Issue30071PlaceholderCharacterSpacingShouldApply.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/Issue30071PlaceholderCharacterSpacingShouldApply.png new file mode 100644 index 000000000000..68bf6c0dfe6b Binary files /dev/null and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/Issue30071PlaceholderCharacterSpacingShouldApply.png differ diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/Issue30071PlaceholderCharacterSpacingShouldChange.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/Issue30071PlaceholderCharacterSpacingShouldChange.png new file mode 100644 index 000000000000..ec11a52694a0 Binary files /dev/null and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/Issue30071PlaceholderCharacterSpacingShouldChange.png differ diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue30071.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue30071.cs new file mode 100644 index 000000000000..16fe8dfb0a70 --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue30071.cs @@ -0,0 +1,57 @@ +namespace Maui.Controls.Sample.Issues; + +[Issue(IssueTracker.Github, 30071, "Entry Editor Placeholder CharacterSpacing Property Not Working on Windows", PlatformAffected.UWP)] + +public class Issue30071 : ContentPage +{ + public Issue30071() + { + var label = new Label + { + Text = "Test passes if Entry and Editor Placeholder has character Spacing", + AutomationId = "label", + HorizontalOptions = LayoutOptions.Center, + VerticalOptions = LayoutOptions.Center, + }; + + var entry = new Entry + { + Placeholder = "Enter text here", + CharacterSpacing = 10, + AutomationId = "entry", + HorizontalOptions = LayoutOptions.Center, + VerticalOptions = LayoutOptions.Center, + }; + + var editor = new Editor + { + Placeholder = "Enter text here", + CharacterSpacing = 10, + HeightRequest = 100, + WidthRequest = 300, + HorizontalOptions = LayoutOptions.Center, + VerticalOptions = LayoutOptions.Center, + }; + + var button = new Button + { + Text = "Change Character Spacing to 20", + AutomationId = "button", + HorizontalOptions = LayoutOptions.Center, + Margin = 10 + }; + + button.Clicked += (s, e) => + { + entry.CharacterSpacing = 20; + editor.CharacterSpacing = 20; + }; + + Content = new StackLayout + { + Children = { label, entry, editor, button }, + Spacing = 20, + Margin = new Thickness(20) + }; + } +} \ No newline at end of file diff --git a/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/Issue30071PlaceholderCharacterSpacingShouldApply.png b/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/Issue30071PlaceholderCharacterSpacingShouldApply.png new file mode 100644 index 000000000000..9d91f896ab80 Binary files /dev/null and b/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/Issue30071PlaceholderCharacterSpacingShouldApply.png differ diff --git a/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/Issue30071PlaceholderCharacterSpacingShouldChange.png b/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/Issue30071PlaceholderCharacterSpacingShouldChange.png new file mode 100644 index 000000000000..a25331f12eb8 Binary files /dev/null and b/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/Issue30071PlaceholderCharacterSpacingShouldChange.png differ diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30071.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30071.cs new file mode 100644 index 000000000000..ae70fbb8a169 --- /dev/null +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30071.cs @@ -0,0 +1,33 @@ +using NUnit.Framework; +using UITest.Appium; +using UITest.Core; + +namespace Microsoft.Maui.TestCases.Tests.Issues; + +public class Issue30071 : _IssuesUITest +{ + public Issue30071(TestDevice device) + : base(device) + { + } + + public override string Issue => "Entry Editor Placeholder CharacterSpacing Property Not Working on Windows"; + + [Test] + [Category(UITestCategories.Entry)] + public void Issue30071PlaceholderCharacterSpacingShouldApply() + { + App.WaitForElement("label"); + VerifyScreenshot(); + } + + [Test] + [Category(UITestCategories.Entry)] + public void Issue30071PlaceholderCharacterSpacingShouldChange() + { + App.WaitForElement("entry"); + App.WaitForElement("button"); + App.Tap("button"); + VerifyScreenshot(); + } +} diff --git a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/Issue30071PlaceholderCharacterSpacingShouldApply.png b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/Issue30071PlaceholderCharacterSpacingShouldApply.png new file mode 100644 index 000000000000..ce1869305727 Binary files /dev/null and b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/Issue30071PlaceholderCharacterSpacingShouldApply.png differ diff --git a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/Issue30071PlaceholderCharacterSpacingShouldChange.png b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/Issue30071PlaceholderCharacterSpacingShouldChange.png new file mode 100644 index 000000000000..f62ba613cac0 Binary files /dev/null and b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/Issue30071PlaceholderCharacterSpacingShouldChange.png differ diff --git a/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios-26/Issue30071PlaceholderCharacterSpacingShouldApply.png b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios-26/Issue30071PlaceholderCharacterSpacingShouldApply.png new file mode 100644 index 000000000000..369f0e4d2a45 Binary files /dev/null and b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios-26/Issue30071PlaceholderCharacterSpacingShouldApply.png differ diff --git a/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios-26/Issue30071PlaceholderCharacterSpacingShouldChange.png b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios-26/Issue30071PlaceholderCharacterSpacingShouldChange.png new file mode 100644 index 000000000000..b2cf273ed769 Binary files /dev/null and b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios-26/Issue30071PlaceholderCharacterSpacingShouldChange.png differ diff --git a/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/Issue30071PlaceholderCharacterSpacingShouldApply.png b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/Issue30071PlaceholderCharacterSpacingShouldApply.png new file mode 100644 index 000000000000..369f0e4d2a45 Binary files /dev/null and b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/Issue30071PlaceholderCharacterSpacingShouldApply.png differ diff --git a/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/Issue30071PlaceholderCharacterSpacingShouldChange.png b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/Issue30071PlaceholderCharacterSpacingShouldChange.png new file mode 100644 index 000000000000..b2cf273ed769 Binary files /dev/null and b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/Issue30071PlaceholderCharacterSpacingShouldChange.png differ diff --git a/src/Core/src/Platform/Windows/TextBoxExtensions.cs b/src/Core/src/Platform/Windows/TextBoxExtensions.cs index a1c8da2dad7e..1f3e20620a18 100644 --- a/src/Core/src/Platform/Windows/TextBoxExtensions.cs +++ b/src/Core/src/Platform/Windows/TextBoxExtensions.cs @@ -75,7 +75,27 @@ public static void UpdateTextColor(this TextBox textBox, ITextStyle textStyle) public static void UpdateCharacterSpacing(this TextBox textBox, ITextStyle textStyle) { - textBox.CharacterSpacing = textStyle.CharacterSpacing.ToEm(); + var characterSpacing = textStyle.CharacterSpacing.ToEm(); + textBox.CharacterSpacing = characterSpacing; + + if (textBox.IsLoaded) + { + ApplyCharacterSpacingToPlaceholder(textBox, characterSpacing); + } + else + { + textBox.OnLoaded(() => ApplyCharacterSpacingToPlaceholder(textBox, characterSpacing)); + } + } + + static void ApplyCharacterSpacingToPlaceholder(this TextBox textBox, int characterSpacing) + { + var placeholderTextBlock = textBox.GetDescendantByName("PlaceholderTextContentPresenter"); + if (placeholderTextBlock is not null) + { + placeholderTextBlock.CharacterSpacing = characterSpacing; + placeholderTextBlock.RefreshThemeResources(); + } } public static void UpdateReturnType(this TextBox textBox, ITextInput textInput)