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

Correctly re-apply font formatting to HTML text #14701

Merged
merged 4 commits into from
Apr 27, 2023
Merged

Conversation

mattleibow
Copy link
Member

Description of Change

Setting the text on iOS resets all formatting, so we need to re-apply size, color and other properties.

Issues Fixed

Fixes #12230
Fixes #11817

Setting the text on iOS resets all formatting, so we need to re-apply size, color and other properties.
}

public static void MapText(ILabelHandler handler, Label label)
{
Platform.TextViewExtensions.UpdateText(handler.PlatformView, label);
}

// TODO: NET8 make this public
internal static void MapTextColor(ILabelHandler handler, Label label)
Copy link
Member Author

Choose a reason for hiding this comment

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

No longer needed as the new way of Platform.TextViewExtensions.UpdateText() correctly handles span colors. There is no difference with either HTML of formatted text.

Platform.TextExtensions.UpdateText(handler.PlatformView, label);
handler.UpdateValue(nameof(ILabel.Text));
Copy link
Member Author

Choose a reason for hiding this comment

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

Instead of calling the same method, we should be triggering the Text property so people can properly intercept it.

Comment on lines +26 to +27

MapFormatting(handler, label);
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the real iOS fix that re-applied formatting.

Comment on lines +94 to +98
static void MapFormatting(ILabelHandler handler, Label label)
{
handler.UpdateValue(nameof(ILabel.TextColor));
handler.UpdateValue(nameof(ILabel.Font));
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Call the properties that need to be re-applied.

handler.PlatformView?.UpdateHorizontalTextAlignment(label);
handler.UpdateValue(nameof(ILabel.HorizontalTextAlignment));
Copy link
Member Author

Choose a reason for hiding this comment

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

Don't just call the method, trigger the property so that the mappers can re-run.

@mattleibow mattleibow added the backport/suggested The PR author or issue review has suggested that the change should be backported. label Apr 21, 2023
@Eilon Eilon added the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label Apr 21, 2023
@mattleibow mattleibow enabled auto-merge (squash) April 26, 2023 19:01
@mattleibow mattleibow merged commit d11465f into main Apr 27, 2023
@mattleibow mattleibow deleted the dev/fix-ios-html branch April 27, 2023 14:28
@hartez hartez added the backport/NO This change should not be backported. It may break customers. label May 31, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Dec 11, 2023
@Eilon Eilon added area-controls-label Label, Span and removed legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor labels May 13, 2024
@samhouts samhouts added the fixed-in-8.0.0-preview.4.8333 Look for this fix in 8.0.0-preview.4.8333! label Aug 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-label Label, Span backport/NO This change should not be backported. It may break customers. backport/suggested The PR author or issue review has suggested that the change should be backported. fixed-in-8.0.0-preview.4.8333 Look for this fix in 8.0.0-preview.4.8333!
Projects
None yet
5 participants