Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
68 changes: 68 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue31496.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using Microsoft.Maui.Layouts;

namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 31496, "BoxView in AbsoluteLayout does not return to default AutoSize", PlatformAffected.iOS | PlatformAffected.macOS)]
public class Issue31496 : ContentPage
{
AbsoluteLayout absoluteLayout;
BoxView boxView;
readonly Rect defaultBounds = new Rect(0, 0, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize);

public Issue31496()
{
absoluteLayout = new AbsoluteLayout
{
BackgroundColor = Colors.LightGray
};

var label = new Label
{
Text = "The test passes if a BoxView is not visible in view.",
};
AbsoluteLayout.SetLayoutBounds(label, new Rect(0.5, 0.80, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));
AbsoluteLayout.SetLayoutFlags(label, AbsoluteLayoutFlags.PositionProportional);

boxView = new BoxView
{
Color = Colors.Green
};
AbsoluteLayout.SetLayoutBounds(boxView, new Rect(0, 0, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));
AbsoluteLayout.SetLayoutFlags(boxView, AbsoluteLayoutFlags.None);

var changeBoundsButton = new Button
{
Text = "Change Bounds",
AutomationId = "Issue31496ChangeBoundsButton"
};
AbsoluteLayout.SetLayoutBounds(changeBoundsButton, new Rect(0.5, 0.90, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));
AbsoluteLayout.SetLayoutFlags(changeBoundsButton, AbsoluteLayoutFlags.PositionProportional);
changeBoundsButton.Clicked += OnChangeBoundsClicked;

var resetBoundsButton = new Button
{
Text = "Reset Bounds",
AutomationId = "Issue31496ResetButton"
};
AbsoluteLayout.SetLayoutBounds(resetBoundsButton, new Rect(0.5, 0.99, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));
AbsoluteLayout.SetLayoutFlags(resetBoundsButton, AbsoluteLayoutFlags.PositionProportional);
resetBoundsButton.Clicked += OnResetBoundsClicked;

absoluteLayout.Children.Add(boxView);
absoluteLayout.Children.Add(label);
absoluteLayout.Children.Add(changeBoundsButton);
absoluteLayout.Children.Add(resetBoundsButton);

Content = absoluteLayout;
}

void OnChangeBoundsClicked(object sender, EventArgs e)
{
AbsoluteLayout.SetLayoutBounds(boxView, new Rect(50, 50, 100, 100));
}

void OnResetBoundsClicked(object sender, EventArgs e)
{
AbsoluteLayout.SetLayoutBounds(boxView, defaultBounds);
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue31496 : _IssuesUITest
{
public Issue31496(TestDevice testDevice) : base(testDevice)
{
}
public override string Issue => "BoxView in AbsoluteLayout does not return to default AutoSize";

[Test]
[Category(UITestCategories.Layout)]
public void BoxViewInAbsoluteLayoutReturnsToDefaultAutoSize()
{
App.WaitForElement("Issue31496ChangeBoundsButton");
App.Tap("Issue31496ChangeBoundsButton");
App.WaitForElement("Issue31496ResetButton");
App.Tap("Issue31496ResetButton");
VerifyScreenshot();
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions src/Core/src/Handlers/ShapeView/ShapeViewHandler.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,22 @@ public static void MapStrokeMiterLimit(IShapeViewHandler handler, IShapeView sha
{
handler.PlatformView?.InvalidateShape(shapeView);
}

public override Size GetDesiredSize(double widthConstraint, double heightConstraint)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is causing some failing tests on iOS and Mac.
image
Could you take a look?

Example:
Shape_Polygon_Pentagon
image

Copy link
Contributor Author

@Dhivya-SF4094 Dhivya-SF4094 Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jsuarezruiz,

The test case Line_StrokeColor_Thickness passed with my fix.

The following four test cases failed both with and without my fix. So failure is not related to my fix.

  1. PolyLine_Points_Thickness
  2. Shape_Polygon_Pentagon
  3. Polygon_StrokeColor_Thickness
  4. Polygon_FillColorWithStrokeColor_Shadow

I have ensured with net 10 branch and test fails in net 10 also.
For example:

image

{
var result = base.GetDesiredSize(widthConstraint, heightConstraint);

if (double.IsNaN(VirtualView.Width))
{
result.Width = 0;
}

if (double.IsNaN(VirtualView.Height))
{
result.Height = 0;
}

return result;
}
}
}
1 change: 1 addition & 0 deletions src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,4 @@ virtual Microsoft.Maui.SwipeViewSwipeStarted.<Clone>$() -> Microsoft.Maui.SwipeV
virtual Microsoft.Maui.SwipeViewSwipeStarted.EqualityContract.get -> System.Type!
virtual Microsoft.Maui.SwipeViewSwipeStarted.Equals(Microsoft.Maui.SwipeViewSwipeStarted? other) -> bool
virtual Microsoft.Maui.SwipeViewSwipeStarted.PrintMembers(System.Text.StringBuilder! builder) -> bool
override Microsoft.Maui.Handlers.ShapeViewHandler.GetDesiredSize(double widthConstraint, double heightConstraint) -> Microsoft.Maui.Graphics.Size
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,4 @@ virtual Microsoft.Maui.SwipeViewSwipeStarted.<Clone>$() -> Microsoft.Maui.SwipeV
virtual Microsoft.Maui.SwipeViewSwipeStarted.EqualityContract.get -> System.Type!
virtual Microsoft.Maui.SwipeViewSwipeStarted.Equals(Microsoft.Maui.SwipeViewSwipeStarted? other) -> bool
virtual Microsoft.Maui.SwipeViewSwipeStarted.PrintMembers(System.Text.StringBuilder! builder) -> bool
override Microsoft.Maui.Handlers.ShapeViewHandler.GetDesiredSize(double widthConstraint, double heightConstraint) -> Microsoft.Maui.Graphics.Size