Skip to content

Commit

Permalink
Merge pull request unoplatform#13691 from Youssef1313/issues/13672
Browse files Browse the repository at this point in the history
fix: Don't skip arrange if the element is measured with zero size
  • Loading branch information
jeromelaban authored Sep 22, 2023
2 parents 8d1f0b0 + 4c7390c commit 8402b30
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand All @@ -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]
Expand Down
8 changes: 1 addition & 7 deletions src/Uno.UI/UI/Xaml/UIElement.Layout.crossruntime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 8402b30

Please sign in to comment.