Skip to content
Open
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
6 changes: 3 additions & 3 deletions src/Controls/src/Core/Label/Label.Mapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,23 +111,23 @@ public static void MapTextColor(LabelHandler handler, Label label) =>

static void MapLineHeight(ILabelHandler handler, Label label, Action<IElementHandler, IElement> baseMethod)
{
if (!IsPlainText(label))
if (label.HasFormattedTextSpans)
return;

baseMethod?.Invoke(handler, label);
}

static void MapTextDecorations(ILabelHandler handler, Label label, Action<IElementHandler, IElement> baseMethod)
{
if (!IsPlainText(label))
if (label.HasFormattedTextSpans)
return;

baseMethod?.Invoke(handler, label);
}

static void MapCharacterSpacing(ILabelHandler handler, Label label, Action<IElementHandler, IElement> baseMethod)
{
if (!IsPlainText(label))
if (label.HasFormattedTextSpans)
return;

baseMethod?.Invoke(handler, label);
Expand Down
3 changes: 3 additions & 0 deletions src/Controls/src/Core/Label/Label.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ internal static void MapFormatting(ILabelHandler handler, Label label)
{
handler.UpdateValue(nameof(ILabel.TextColor));
handler.UpdateValue(nameof(ILabel.Font));
handler.UpdateValue(nameof(ILabel.LineHeight));
handler.UpdateValue(nameof(ILabel.TextDecorations));
handler.UpdateValue(nameof(ILabel.CharacterSpacing));
}
}

Expand Down
27 changes: 27 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue22197.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?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"
xmlns:local="clr-namespace:Maui.Controls.Sample.Issues"
x:Class="Maui.Controls.Sample.Issues.Issue22197">
<VerticalStackLayout>
<Label
TextType="Html"
FontSize="15"
TextDecorations="Underline"
CharacterSpacing="5"
Text="Etiam sodales sollicitudin diam, vel tincidunt libero eleifend id. Vestibulum vehicula congue velit, id egestas nulla pellentesque at."
LineHeight="2">
</Label>
<Label
AutomationId="label"
Copy link

Copilot AI Aug 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The AutomationId 'label' is too generic and could conflict with other elements. Consider using a more specific identifier like 'htmlTextTypeLabel' to ensure uniqueness across all test cases.

Copilot uses AI. Check for mistakes.
Text="HTML Text type"/>
<Label
TextDecorations="Underline"
FontSize="15"
CharacterSpacing="5"
LineHeight="2"
Text="Etiam sodales sollicitudin diam, vel tincidunt libero eleifend id. Vestibulum vehicula congue velit, id egestas nulla pellentesque at."/>
<Label Text="Plain Text type"/>
</VerticalStackLayout>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would exercise the line height feature more:

Suggested change
</VerticalStackLayout>
<!-- Exercise line heights less than 1. -->
<Label BackgroundColor="Green" FontSize="20" Text="ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ"/>
<Label BackgroundColor="Red" LineHeight="0.8" FontSize="20" Text="ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ"/>
<Label BackgroundColor="Green" LineHeight="0.2" FontSize="20" Text="ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ"/>
<Label BackgroundColor="Red" LineHeight="0.4" FontSize="20" Text="ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ"/>
<Label BackgroundColor="Green" LineHeight="1.0" FontSize="20" Text="ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ"/>
<Label BackgroundColor="Red" LineHeight="1.2" FontSize="20" Text="ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ"/>
<Label BackgroundColor="Green" LineHeight="1.4" FontSize="20" Text="ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ"/>
<Label BackgroundColor="Red" LineHeight="1.6" FontSize="20" Text="ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ"/>
<Label BackgroundColor="Green" LineHeight="2.0" FontSize="20" Text="ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ"/>
<Label BackgroundColor="Red" LineHeight="4.6" FontSize="20" Text="ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ"/>
</VerticalStackLayout>

See comment #24520 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm but this pr is not about lineHeight in this sense. It is about the line Height for HTML labels

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I moved the comment to #31219.

</ContentPage>
10 changes: 10 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue22197.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 22197, "LineHeight with HTML Label not working")]
public partial class Issue22197 : ContentPage
{
public Issue22197()
{
InitializeComponent();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue22197 : _IssuesUITest
{
public Issue22197(TestDevice testDevice) : base(testDevice) { }

public override string Issue => "LineHeight with HTML Label not working";

[Test]
[Category(UITestCategories.Label)]
public void LineHeightWithHTMLLabelShouldWork()
{
App.WaitForElement("label");
VerifyScreenshot();
}
}