LineHeight and decorations for HTML Label - fix#31202
LineHeight and decorations for HTML Label - fix#31202kubaflo wants to merge 1 commit intodotnet:mainfrom
Conversation
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.
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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.
|
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. |
| 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> |
There was a problem hiding this comment.
This would exercise the line height feature more:
| </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)
There was a problem hiding this comment.
Hmmm but this pr is not about lineHeight in this sense. It is about the line Height for HTML labels

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