From a06ae34732d5c897b9a627cbe13836e0bafb1943 Mon Sep 17 00:00:00 2001 From: Danich54rus <30523543+Danich27rus@users.noreply.github.com> Date: Wed, 30 Oct 2024 11:20:39 +0700 Subject: [PATCH] Fix InlineUIContainer clipping in text when ArrangeOverride called. (#17183) (#17194) * InlineUiContainer clip fix * Removed LINQ, redo check * bugfix/InlineUiContainer-clip-in-text: redo everything * fixes by Gillibald --------- Co-authored-by: Benedikt Stebner --- src/Avalonia.Controls/TextBlock.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Controls/TextBlock.cs b/src/Avalonia.Controls/TextBlock.cs index 377cfc1ba83..afa7d3542ae 100644 --- a/src/Avalonia.Controls/TextBlock.cs +++ b/src/Avalonia.Controls/TextBlock.cs @@ -759,7 +759,10 @@ protected override Size ArrangeOverride(Size finalSize) var textLayout = TextLayout; if (HasComplexContent) - { + { + //Clear visual children before complex run arrangement + VisualChildren.Clear(); + var currentY = padding.Top; foreach (var textLine in textLayout.TextLines) @@ -773,6 +776,10 @@ protected override Size ArrangeOverride(Size finalSize) if (drawable is EmbeddedControlRun controlRun && controlRun.Control is Control control) { + //Add again to prevent clipping + //Fixes: #17194 + VisualChildren.Add(control); + control.Arrange( new Rect(new Point(currentX, currentY), new Size(control.DesiredSize.Width, textLine.Height))); @@ -964,6 +971,6 @@ public InlinesTextSource(IReadOnlyList textRuns, IReadOnlyList