Skip to content

Commit 1293cb5

Browse files
kubafloPureWeen
authored andcommitted
[iOS] FormattedText with text color causes stack overflow - fix (#29874)
1 parent 4d0efba commit 1293cb5

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

src/Controls/src/Core/Label/Label.iOS.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ internal static void MapFormatting(ILabelHandler handler, Label label)
4242
{
4343
LabelHandler.MapFormatting(handler, label);
4444
}
45-
else
45+
else if (!label.HasFormattedTextSpans && label.TextType == TextType.Html) // we need to re-apply color and font for HTML labels
4646
{
4747
handler.UpdateValue(nameof(ILabel.TextColor));
4848
handler.UpdateValue(nameof(ILabel.Font));
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
namespace Maui.Controls.Sample.Issues;
2+
3+
[Issue(IssueTracker.Github, 29851, "[iOS] FormattedText with text color causes stack overflow", PlatformAffected.All)]
4+
public class Issue29851 : TestContentPage
5+
{
6+
protected override void Init()
7+
{
8+
Content = new Label
9+
{
10+
AutomationId = "label",
11+
TextColor = Colors.Green,
12+
FormattedText = new FormattedString
13+
{
14+
Spans =
15+
{
16+
new Span { Text = "Hello, World!" },
17+
new Span { Text = "*", TextColor = Colors.Red }
18+
}
19+
}
20+
};
21+
;
22+
}
23+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using NUnit.Framework;
2+
using UITest.Appium;
3+
using UITest.Core;
4+
5+
namespace Microsoft.Maui.TestCases.Tests.Issues;
6+
7+
public class Issue29851 : _IssuesUITest
8+
{
9+
10+
public Issue29851(TestDevice testDevice) : base(testDevice) { }
11+
12+
public override string Issue => "[iOS] FormattedText with text color causes stack overflow";
13+
14+
[Test]
15+
[Category(UITestCategories.Label)]
16+
public void FormattedTextWithTextColorDoesNotCrash()
17+
{
18+
App.WaitForElement("label");
19+
}
20+
}

0 commit comments

Comments
 (0)