Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 57 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue30071.cs
Original file line number Diff line number Diff line change
@@ -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)
};
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -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()
{

Check failure on line 19 in src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30071.cs

View check run for this annotation

Azure Pipelines / maui-pr (Build .NET MAUI Build macOS (Debug))

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30071.cs#L19

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30071.cs(19,14): error MAUI0002: (NETCORE_ENGINEERING_TELEMETRY=Build) Test method 'Issue30071PlaceholderCharacterSpacingShouldApply' has 2 `[Category]` attributes but should have exactly one

Check failure on line 19 in src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30071.cs

View check run for this annotation

Azure Pipelines / maui-pr (Build .NET MAUI Build macOS (Debug))

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30071.cs#L19

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30071.cs(19,14): error MAUI0002: (NETCORE_ENGINEERING_TELEMETRY=Build) Test method 'Issue30071PlaceholderCharacterSpacingShouldApply' has 2 `[Category]` attributes but should have exactly one

Check failure on line 19 in src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30071.cs

View check run for this annotation

Azure Pipelines / maui-pr (Build .NET MAUI Build macOS (Debug))

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30071.cs#L19

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30071.cs(19,14): error MAUI0002: (NETCORE_ENGINEERING_TELEMETRY=Build) Test method 'Issue30071PlaceholderCharacterSpacingShouldApply' has 2 `[Category]` attributes but should have exactly one

Check failure on line 19 in src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30071.cs

View check run for this annotation

Azure Pipelines / maui-pr (Build .NET MAUI Build macOS (Release))

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30071.cs#L19

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30071.cs(19,14): error MAUI0002: (NETCORE_ENGINEERING_TELEMETRY=Build) Test method 'Issue30071PlaceholderCharacterSpacingShouldApply' has 2 `[Category]` attributes but should have exactly one

Check failure on line 19 in src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30071.cs

View check run for this annotation

Azure Pipelines / maui-pr (Build .NET MAUI Build macOS (Release))

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30071.cs#L19

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30071.cs(19,14): error MAUI0002: (NETCORE_ENGINEERING_TELEMETRY=Build) Test method 'Issue30071PlaceholderCharacterSpacingShouldApply' has 2 `[Category]` attributes but should have exactly one

Check failure on line 19 in src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30071.cs

View check run for this annotation

Azure Pipelines / maui-pr (Build .NET MAUI Build macOS (Release))

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30071.cs#L19

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30071.cs(19,14): error MAUI0002: (NETCORE_ENGINEERING_TELEMETRY=Build) Test method 'Issue30071PlaceholderCharacterSpacingShouldApply' has 2 `[Category]` attributes but should have exactly one
App.WaitForElement("label");
VerifyScreenshot();
}

[Test]
[Category(UITestCategories.Entry)]
public void Issue30071PlaceholderCharacterSpacingShouldChange()
{
App.WaitForElement("entry");

Check failure on line 28 in src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30071.cs

View check run for this annotation

Azure Pipelines / maui-pr (Build .NET MAUI Build macOS (Debug))

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30071.cs#L28

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30071.cs(28,14): error MAUI0002: (NETCORE_ENGINEERING_TELEMETRY=Build) Test method 'Issue30071PlaceholderCharacterSpacingShouldChange' has 2 `[Category]` attributes but should have exactly one

Check failure on line 28 in src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30071.cs

View check run for this annotation

Azure Pipelines / maui-pr (Build .NET MAUI Build macOS (Debug))

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30071.cs#L28

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30071.cs(28,14): error MAUI0002: (NETCORE_ENGINEERING_TELEMETRY=Build) Test method 'Issue30071PlaceholderCharacterSpacingShouldChange' has 2 `[Category]` attributes but should have exactly one

Check failure on line 28 in src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30071.cs

View check run for this annotation

Azure Pipelines / maui-pr (Build .NET MAUI Build macOS (Release))

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30071.cs#L28

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30071.cs(28,14): error MAUI0002: (NETCORE_ENGINEERING_TELEMETRY=Build) Test method 'Issue30071PlaceholderCharacterSpacingShouldChange' has 2 `[Category]` attributes but should have exactly one

Check failure on line 28 in src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30071.cs

View check run for this annotation

Azure Pipelines / maui-pr (Build .NET MAUI Build macOS (Release))

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30071.cs#L28

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30071.cs(28,14): error MAUI0002: (NETCORE_ENGINEERING_TELEMETRY=Build) Test method 'Issue30071PlaceholderCharacterSpacingShouldChange' has 2 `[Category]` attributes but should have exactly one
App.WaitForElement("button");
App.Tap("button");
VerifyScreenshot();
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 21 additions & 1 deletion src/Core/src/Platform/Windows/TextBoxExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<TextBlock>("PlaceholderTextContentPresenter");
if (placeholderTextBlock is not null)
{
placeholderTextBlock.CharacterSpacing = characterSpacing;
placeholderTextBlock.RefreshThemeResources();
}
}

public static void UpdateReturnType(this TextBox textBox, ITextInput textInput)
Expand Down
Loading