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

[Windows] Fix for the issue with Label text color when resetting from FormattedText. #25119

Merged
merged 15 commits into from
Oct 15, 2024

Conversation

Tamilarasan-Paranthaman
Copy link
Contributor

@Tamilarasan-Paranthaman Tamilarasan-Paranthaman commented Oct 7, 2024

Root Cause of the issue

When changing the label text to FormattedText with text color, and then switching back to normal text, the text retains the formatted text color. This is due to the TextHighlighter applied in the UpdateInlines method of FormattedStringExtensions, which is not cleared when reverting to normal text.

Description of Change

I cleared the TextHighlighters in the UpdateText method of the TextBlockExtensions class before setting the normal text, which resolves the issue and works fine.

Issues Fixed

Fixes #24516

Tested the behaviour in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

Screenshot

Before Issue Fix After Issue Fix
FormattedTextIssue.mp4
FormattedTextColorFixed.mp4

@jsuarezruiz
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@Tamilarasan-Paranthaman Tamilarasan-Paranthaman marked this pull request as ready for review October 8, 2024 11:05
@Tamilarasan-Paranthaman Tamilarasan-Paranthaman requested a review from a team as a code owner October 8, 2024 11:05
@jsuarezruiz
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen
Copy link
Member

PureWeen commented Oct 8, 2024

/rebase

@jsuarezruiz
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@Tamilarasan-Paranthaman
Copy link
Contributor Author

/rebase

@jsuarezruiz
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@@ -55,7 +55,9 @@ public partial class Label : View, IFontElement, ITextElement, ITextAlignmentEle
{
var formattedString = ((FormattedString)oldvalue);
var label = ((Label)bindable);

#if WINDOWS
(label.Handler as LabelHandler)?.PlatformView?.TextHighlighters?.Clear();
Copy link
Member

Choose a reason for hiding this comment

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

Can this be moved to here?

Platform.TextBlockExtensions.UpdateText(handler.PlatformView, label);

Or into the extention method being called?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have moved the fix into the TextBlockExtensions and ensured that the issue is resolved. Please review it and share if you have any concerns.

@jsuarezruiz
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen PureWeen merged commit d1911b0 into dotnet:main Oct 15, 2024
97 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Nov 16, 2024
@sheiksyedm sheiksyedm added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Dec 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-label Label, Span community ✨ Community Contribution fixed-in-9.0.10 partner/syncfusion Issues / PR's with Syncfusion collaboration platform/windows 🪟
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rendering issue in WinUI when setting Label.FormattedText
6 participants