diff --git a/src/Controls/src/Core/Entry/Entry.Mapper.cs b/src/Controls/src/Core/Entry/Entry.Mapper.cs index 413f01b94078..6dec362d909f 100644 --- a/src/Controls/src/Core/Entry/Entry.Mapper.cs +++ b/src/Controls/src/Core/Entry/Entry.Mapper.cs @@ -18,7 +18,7 @@ public partial class Entry EntryHandler.Mapper.ReplaceMapping(PlatformConfiguration.iOSSpecific.Entry.AdjustsFontSizeToFitWidthProperty.PropertyName, MapAdjustsFontSizeToFitWidth); #endif EntryHandler.Mapper.ReplaceMapping(nameof(Text), MapText); - EntryHandler.Mapper.ReplaceMapping(nameof(TextTransform), MapText); + EntryHandler.Mapper.ReplaceMapping(nameof(TextTransform), MapTextTransform); #if IOS || ANDROID EntryHandler.Mapper.AppendToMapping(nameof(VisualElement.IsFocused), InputView.MapIsFocused); @@ -28,5 +28,16 @@ public partial class Entry EntryHandler.CommandMapper.PrependToMapping(nameof(IEntry.Focus), InputView.MapFocus); #endif } + + static void MapTextTransform(IEntryHandler handler, Entry label) + { + if (label.IsConnectingHandler()) + { + // If we're connecting the handler, we don't want to map the text multiple times. + return; + } + + MapText(handler, label); + } } } diff --git a/src/Controls/src/Core/Entry/Entry.iOS.cs b/src/Controls/src/Core/Entry/Entry.iOS.cs index 25a6281483a1..20407ae151b3 100644 --- a/src/Controls/src/Core/Entry/Entry.iOS.cs +++ b/src/Controls/src/Core/Entry/Entry.iOS.cs @@ -16,7 +16,14 @@ public static void MapAdjustsFontSizeToFitWidth(IEntryHandler handler, Entry ent public static void MapText(IEntryHandler handler, Entry entry) { Platform.TextExtensions.UpdateText(handler.PlatformView, entry); - EntryHandler.MapFormatting(handler, entry); + + if (!handler.IsConnectingHandler()) + { + // If we're not connecting the handler, we need to update the text formatting + // This is because the text may have changed, and we need to ensure that + // any attributed string formatting is applied correctly. + EntryHandler.MapFormatting(handler, entry); + } } public static void MapCursorColor(EntryHandler handler, Entry entry) => diff --git a/src/Controls/src/Core/Label/Label.Mapper.cs b/src/Controls/src/Core/Label/Label.Mapper.cs index fdc6a046daea..3057ce3cf6d2 100644 --- a/src/Controls/src/Core/Label/Label.Mapper.cs +++ b/src/Controls/src/Core/Label/Label.Mapper.cs @@ -57,7 +57,10 @@ static void MapTextTransform(ILabelHandler handler, Label label) => static void MapFormattedText(ILabelHandler handler, Label label) { if (label.IsConnectingHandler()) + { + // If we're connecting the handler, we don't want to map the text multiple times. return; + } MapText(handler, label); } @@ -139,9 +142,12 @@ static void MapFont(ILabelHandler handler, Label label, Action