From 4c7390c87ca051412d18c27c696476c37187049a Mon Sep 17 00:00:00 2001 From: Youssef Victor Date: Tue, 19 Sep 2023 11:09:21 +0300 Subject: [PATCH] fix: Don't skip arrange if the element is measured with zero size --- .../Tests/Windows_UI_Xaml_Controls/Given_StackPanel.cs | 8 ++------ src/Uno.UI/UI/Xaml/UIElement.Layout.crossruntime.cs | 8 +------- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_StackPanel.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_StackPanel.cs index 01eb29835b98..e65082ad3282 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_StackPanel.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_StackPanel.cs @@ -97,14 +97,12 @@ public async Task When_Adding_Or_Removing_Child_Should_Re_Measure() Assert.AreEqual(50, SUT.LastArrangeOverrideReturn.Height); SUT.Children.Remove(SUT.Children.Single()); -#if !__CROSSRUNTIME__ - await TestServices.WindowHelper.WaitForRelayouted(SUT); // arrange is skipped (incorrectly) when finalRect is default, which is the case after removing the last child from StackPanel. + await TestServices.WindowHelper.WaitForRelayouted(SUT); expectedMeasureAndArrangeCount++; Assert.AreEqual(expectedMeasureAndArrangeCount, SUT.MeasureCount); Assert.AreEqual(expectedMeasureAndArrangeCount, SUT.ArrangeCount); Assert.AreEqual(0, SUT.LastMeasureOverrideReturn.Height); Assert.AreEqual(0, SUT.LastArrangeOverrideReturn.Height); -#endif SUT.Children.Add(new Border() { @@ -119,14 +117,12 @@ public async Task When_Adding_Or_Removing_Child_Should_Re_Measure() Assert.AreEqual(50, SUT.LastArrangeOverrideReturn.Height); SUT.Children.Clear(); -#if !__CROSSRUNTIME__ - await TestServices.WindowHelper.WaitForRelayouted(SUT); // arrange is skipped (incorrectly) when finalRect is default, which is the case after removing the last child from StackPanel. + await TestServices.WindowHelper.WaitForRelayouted(SUT); expectedMeasureAndArrangeCount++; Assert.AreEqual(expectedMeasureAndArrangeCount, SUT.MeasureCount); Assert.AreEqual(expectedMeasureAndArrangeCount, SUT.ArrangeCount); Assert.AreEqual(0, SUT.LastMeasureOverrideReturn.Height); Assert.AreEqual(0, SUT.LastArrangeOverrideReturn.Height); -#endif } [TestMethod] diff --git a/src/Uno.UI/UI/Xaml/UIElement.Layout.crossruntime.cs b/src/Uno.UI/UI/Xaml/UIElement.Layout.crossruntime.cs index 35abcc7c7ec1..dbcae6a6901a 100644 --- a/src/Uno.UI/UI/Xaml/UIElement.Layout.crossruntime.cs +++ b/src/Uno.UI/UI/Xaml/UIElement.Layout.crossruntime.cs @@ -304,13 +304,7 @@ public void Arrange(Rect finalRect) var firstArrangeDone = IsFirstArrangeDone; - if (Visibility == Visibility.Collapsed - // If the layout is clipped, and the arranged size is empty, we can skip arranging children - // This scenario is particularly important for the Canvas which always sets its desired size - // zero, even after measuring its children. - || (firstArrangeDone - && finalRect == default - && (this is not ICustomClippingElement clipElement || clipElement.AllowClippingToLayoutSlot))) + if (Visibility == Visibility.Collapsed) { LayoutInformation.SetLayoutSlot(this, finalRect); HideVisual();