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] Fix for the issue with Label text color when resetting from FormattedText. #25119

Merged
merged 15 commits into from
Oct 15, 2024
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
Expand Up @@ -34,7 +34,13 @@ public static void UpdateText(this TextBlock platformControl, Label label)
if (label.FormattedText != null)
platformControl.UpdateInlines(label);
else
{
if (platformControl.TextHighlighters.Count > 0)
{
platformControl.TextHighlighters.Clear();
}
platformControl.Text = TextTransformUtilites.GetTransformedText(label.Text, label.TextTransform);
}
break;
}
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue24516.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?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.Issue24516">

<StackLayout Spacing="20"
VerticalOptions="Center"
HorizontalOptions="Center">
<Label x:Name="label"
AutomationId="Label"
Text="Hello, World!" />
<Button AutomationId="Button"
Text="Change Text Type"
Clicked="OnCounterClicked" />
</StackLayout>

</ContentPage>
36 changes: 36 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue24516.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Microsoft.Maui.Controls.Internals;
using Microsoft.Maui.Controls.Xaml;
using Microsoft.Maui.Controls;


namespace Maui.Controls.Sample.Issues
{
[Issue(IssueTracker.Github, 24516, "Rendering issue in WinUI when setting Label.FormattedText", PlatformAffected.UWP)]
public partial class Issue24516 : ContentPage
{
int count = 0;
public Issue24516()
{
InitializeComponent();
}

private void OnCounterClicked(object sender, EventArgs e)
{
count++;
if (count % 2 == 0)
{
label.Text = "Hello, World!";
}
else
{
var formattedString = new FormattedString();
formattedString.Spans.Add(new Span { Text = "Hello", TextColor = Color.FromRgb(0xB0, 0x0F, 0x50) });
formattedString.Spans.Add(new Span { Text = ", World!" });
label.FormattedText = formattedString;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#if !MACCATALYST
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues
{
public class Issue24516 : _IssuesUITest
{
public Issue24516(TestDevice testDevice) : base(testDevice)
{
}

public override string Issue => "Rendering issue in WinUI when setting Label.FormattedText";

[Test]
[Category(UITestCategories.Label)]
public void VerifyLabelTextColorWhenResettingFromFormattedText()
{
App.WaitForElement("Label");
App.Tap("Button");
App.Tap("Button");
VerifyScreenshot();
}
}
}
#endif
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