Skip to content
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

[Windows] Remove workaround for label text decorations #22650

Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#if WINDOWS
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue21787 : _IssuesUITest
{
public Issue21787(TestDevice device) : base(device) { }

public override string Issue => "[Windows] Remove workaround for label text decorations";

[Test]
public void LabelTextDecorationsWorks()
{
App.WaitForElement("TestButton");
App.Tap("TestButton");

VerifyScreenshot();
}
}
#endif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions src/Controls/tests/TestCases/Issues/Issue21787.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Maui.Controls.Sample.Issues.Issue21787">
<VerticalStackLayout>
<Label
x:Name="TestLabel"
AutomationId="TestLabel"
Text="Lorem ipsum dolor sit amet, consectetur adipiscing elit."/>
<Button
AutomationId="TestButton"
Text="Update"
Clicked="OnUpdateButtonClicked"/>
</VerticalStackLayout>
</ContentPage>
29 changes: 29 additions & 0 deletions src/Controls/tests/TestCases/Issues/Issue21787.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using Microsoft.Maui;
using Microsoft.Maui.Controls;

namespace Maui.Controls.Sample.Issues
{
[Issue(IssueTracker.None, 21787, "[Windows] Remove workaround for label text decorations", PlatformAffected.UWP)]
public partial class Issue21787 : ContentPage
{
int _counter;

public Issue21787()
{
InitializeComponent();

BindingContext = new ViewModel5354();
}

void OnUpdateButtonClicked(object sender, EventArgs e)
{
_counter++;

if (_counter % 2 == 1)
TestLabel.TextDecorations = TextDecorations.Underline | TextDecorations.Strikethrough;
else
TestLabel.TextDecorations = TextDecorations.None;
}
}
}
26 changes: 0 additions & 26 deletions src/Core/src/Platform/Windows/TextBlockExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,32 +52,6 @@ public static void UpdateTextDecorations(this TextBlock platformControl, ILabel
platformControl.TextDecorations &= ~global::Windows.UI.Text.TextDecorations.Strikethrough;
else
platformControl.TextDecorations |= global::Windows.UI.Text.TextDecorations.Strikethrough;

// TextDecorations are not updated in the UI until the text changes
if (platformControl.Inlines != null && platformControl.Inlines.Count > 0)
{
foreach (var inline in platformControl.Inlines)
{
if (inline is Run run)
{
run.Text = run.Text;
}
else if (inline is Span span)
{
foreach (var inline2 in span.Inlines)
{
if (inline2 is Run run2)
{
run2.Text = run2.Text;
}
}
}
}
}
else
{
platformControl.Text = platformControl.Text;
}
}

public static void UpdateLineHeight(this TextBlock platformControl, ILabel label)
Expand Down
Loading