Skip to content

LineHeight and decorations for HTML Label - fix#31202

Open
kubaflo wants to merge 1 commit intodotnet:mainfrom
kubaflo:fix-22197
Open

LineHeight and decorations for HTML Label - fix#31202
kubaflo wants to merge 1 commit intodotnet:mainfrom
kubaflo:fix-22197

Conversation

@kubaflo
Copy link
Contributor

@kubaflo kubaflo commented Aug 16, 2025

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Description of Change

Corrects mapping logic for LineHeight, TextDecorations, and CharacterSpacing to apply to HTML labels. Updates iOS handler to refresh these properties when TextType changes. Adds test case for Issue22197 to verify correct rendering of HTML labels with these properties.

Issues Fixed

Fixes #22193
Fixes #22197

Before After
Before After

Corrects mapping logic for LineHeight, TextDecorations, and CharacterSpacing to apply to HTML labels. Updates iOS handler to refresh these properties when TextType changes. Adds test case for Issue22197 to verify correct rendering of HTML labels with these properties.
Copilot AI review requested due to automatic review settings August 16, 2025 23:39
@kubaflo kubaflo requested a review from a team as a code owner August 16, 2025 23:39
@kubaflo kubaflo self-assigned this Aug 16, 2025
@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Aug 16, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes issues with LineHeight, TextDecorations, and CharacterSpacing not being applied to HTML labels in .NET MAUI. The fix corrects the mapping logic to allow these properties to work with HTML text type labels, not just plain text labels.

  • Updates the mapper conditions to check for FormattedTextSpans instead of plain text, allowing HTML labels to receive these style properties
  • Modifies the iOS handler to refresh LineHeight, TextDecorations, and CharacterSpacing when TextType changes
  • Adds comprehensive test case to verify the fix works correctly

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Controls/src/Core/Label/Label.Mapper.cs Updates mapping conditions from IsPlainText check to HasFormattedTextSpans check for LineHeight, TextDecorations, and CharacterSpacing
src/Controls/src/Core/Label/Label.iOS.cs Adds refresh calls for LineHeight, TextDecorations, and CharacterSpacing when TextType changes in iOS handler
src/Controls/tests/TestCases.HostApp/Issues/Issue22197.xaml Creates UI test page demonstrating HTML vs plain text labels with styling properties
src/Controls/tests/TestCases.HostApp/Issues/Issue22197.xaml.cs Code-behind for the test page
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue22197.cs NUnit test implementation to verify the fix through screenshot verification

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.
@dotnet-policy-service
Copy link
Contributor

Hey there @@kubaflo! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@kubaflo kubaflo added platform/android platform/ios area-controls-label Label, Span and removed community ✨ Community Contribution labels Aug 16, 2025
@kubaflo kubaflo changed the title Fix LineHeight and decorations for HTML Label LineHeight and decorations for HTML Label - fix Aug 16, 2025
@MartyIX
Copy link
Contributor

MartyIX commented Aug 17, 2025

This is how it looks like on Windows:

image

(For reference purposes)

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lineheight is broken LineHeight with HTML Label not working

2 participants