From d1911b02b45c1ae3d30d012c848beaf2fa90577f Mon Sep 17 00:00:00 2001 From: Tamilarasan Paranthaman <93904422+Tamilarasan-Paranthaman@users.noreply.github.com> Date: Wed, 16 Oct 2024 00:46:51 +0530 Subject: [PATCH] [Windows] Fix for the issue with Label text color when resetting from FormattedText. (#25119) * fixed label formatted text issue. * Modified test sample. * Test sample changes. * Modified test case. * Added snapshots. * Test sample changes. * fixed label formatted text issue. * Modified test sample. * Test sample changes. * Modified test case. * Added snapshots. * Test sample changes. * Modified the fix. * Removed the unwanted changes. --- .../Windows/Extensions/TextBlockExtensions.cs | 6 +++ ...extColorWhenResettingFromFormattedText.png | Bin 0 -> 22826 bytes .../TestCases.HostApp/Issues/Issue24516.xaml | 18 +++++++++ .../Issues/Issue24516.xaml.cs | 36 ++++++++++++++++++ .../Tests/Issues/Issue24516.cs | 27 +++++++++++++ ...extColorWhenResettingFromFormattedText.png | Bin 0 -> 4306 bytes ...extColorWhenResettingFromFormattedText.png | Bin 0 -> 25504 bytes 7 files changed, 87 insertions(+) create mode 100644 src/Controls/tests/TestCases.Android.Tests/snapshots/android/VerifyLabelTextColorWhenResettingFromFormattedText.png create mode 100644 src/Controls/tests/TestCases.HostApp/Issues/Issue24516.xaml create mode 100644 src/Controls/tests/TestCases.HostApp/Issues/Issue24516.xaml.cs create mode 100644 src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue24516.cs create mode 100644 src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelTextColorWhenResettingFromFormattedText.png create mode 100644 src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/VerifyLabelTextColorWhenResettingFromFormattedText.png diff --git a/src/Controls/src/Core/Platform/Windows/Extensions/TextBlockExtensions.cs b/src/Controls/src/Core/Platform/Windows/Extensions/TextBlockExtensions.cs index 8530b4311bc7..41d725179f45 100644 --- a/src/Controls/src/Core/Platform/Windows/Extensions/TextBlockExtensions.cs +++ b/src/Controls/src/Core/Platform/Windows/Extensions/TextBlockExtensions.cs @@ -34,7 +34,13 @@ public static void UpdateText(this TextBlock platformControl, Label label) if (label.FormattedText != null) platformControl.UpdateInlines(label); else + { + if (platformControl.TextHighlighters.Count > 0) + { + platformControl.TextHighlighters.Clear(); + } platformControl.Text = TextTransformUtilites.GetTransformedText(label.Text, label.TextTransform); + } break; } } diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/VerifyLabelTextColorWhenResettingFromFormattedText.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/VerifyLabelTextColorWhenResettingFromFormattedText.png new file mode 100644 index 0000000000000000000000000000000000000000..8751e1477c5faf8307389cac59ccc8c648edcf8b GIT binary patch literal 22826 zcmeHvcT`hpyYIG)=vWv=Dbk`aii&_Jy*eLl6af(tq>f~eCSZinn^Od-GZsKvRD_5$ zL+?=`iFA+>AT$#xl0axF5R#mC&v)**_pEi!KX2DzjI(X?P(`yj4TL*&nkoN8YXE2t-zTj{S`O`Hk2#PofL2FnM+ z9T4RB?IqJ6uZN8>Cc^9N(aqeI-dlT)9$GWlm+6U`^_HVOXwOUc4Rrr)zi=-x#$o)@HXkE5#R_xk(a08!zbn9va*mw*Z_ZKDT28} zaqGL`PaZS8zY83GvY7_Ip-+dmFKt_6+c&nuVH+H_@o+mkY$wERda%uiwi(ejBid#} z+l*+N5p6S~ZAP@sh_)HgHY57qW<*&}KwG|~80y1A(}xMa zezQMuCSan$EJ;FT!M}-4E>GKc_~emJBr$ok6fK>#u{K9~a8O1;;iXl!RzD6&a-A&m z>dot~@)?i|u(P!l6BidJ+{4H4FY{LwU&h1)+S}V#%LlE`_dAzf2wfVdhJ=TQKgr0* zh;RV)7+$Y@!W7xtRV-Ba<}Ho{EAOU zjbow=`0E2=V(K1k33baK_J`JWH=ya%c;l^GC9aKH3JOMBpG8S=J9dTCO;q+8$skFo zDG3R?4(S{#Yg+BNhTnSBz-LpCz%XKBsHOTj;>W)fEe(Hwp5MP9A_5J*2%KsmEIzy7 zMI@%kfM+*_uO-%jw|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