Skip to content

Conversation

Dhivya-SF4094
Copy link
Contributor

@Dhivya-SF4094 Dhivya-SF4094 commented Sep 17, 2025

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Issue Details:

When a BoxView inside an AbsoluteLayout is defined with AutoSize for width and height, and later its bounds are changed to explicit values and then reset back to AutoSize, the reset fails on iOS.

Root Cause

On iOS/macOS, when a BoxView (or any Shape) inside an AbsoluteLayout is reset back to AutoSize, the control remains visible with its previous explicit bounds.
The issue occurs because the Bounds property in PlatformGraphicsView retains the previous size.
During measure, AbsoluteLayout queries the child’s desired size. Since PlatformGraphicsView.Bounds still holds the old value, the shape continues to visible.

Description of Change

Override GetDesiredSize in ShapeViewHandler.iOS.When VirtualView.Width or VirtualView.Height is NaN, set the corresponding dimension in the returned Size to 0.
This ensures that shapes like BoxView collapse correctly when reset to AutoSize, matching Android behavior.
Validated the behavior in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

Reference

public override Size GetDesiredSize(double widthConstraint, double heightConstraint)
{
var result = base.GetDesiredSize(widthConstraint, heightConstraint);
if (double.IsNaN(VirtualView.Width))
{
result.Width = 0;
}
if (double.IsNaN(VirtualView.Height))
{
result.Height = 0;
}
return result;

Issues Fixed:

Fixes #31496

Screenshots

Before After
BeforeFix_31496_iOS.mov
AfterFix_31496_iOS.mov

Copy link
Contributor

Hey there @@Dhivya-SF4094! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@dotnet-policy-service dotnet-policy-service bot added community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration labels Sep 17, 2025
@Dhivya-SF4094 Dhivya-SF4094 marked this pull request as ready for review September 18, 2025 12:46
@Copilot Copilot AI review requested due to automatic review settings September 18, 2025 12:46
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a bug where BoxView controls inside AbsoluteLayout on iOS/macOS did not properly return to their default AutoSize state after being reset from explicit bounds. The issue was that the PlatformGraphicsView retained the previous size values, causing the shape to remain visible with its old dimensions.

  • Overrides the GetDesiredSize method in ShapeViewHandler.iOS.cs to return 0 for width/height when those dimensions are NaN (AutoSize)
  • Adds comprehensive UI tests to validate the fix across platforms
  • Updates public API documentation to reflect the new override method

Reviewed Changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/Core/src/Handlers/ShapeView/ShapeViewHandler.iOS.cs Implements the core fix by overriding GetDesiredSize to handle AutoSize properly
src/Controls/tests/TestCases.HostApp/Issues/Issue31496.cs Creates the UI test page demonstrating the BoxView reset behavior
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue31496.cs Implements the automated test to verify the fix
src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt Documents the new public API method for iOS
src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt Documents the new public API method for macOS

@jsuarezruiz
Copy link
Contributor

/azp run

@jsuarezruiz jsuarezruiz added area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing labels Sep 19, 2025
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@jsuarezruiz
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[iOS, Catalyst] BoxView in AbsoluteLayout does not return to default AutoSize for Height/Width after reset
2 participants