Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arrange on Layouts not respecting correctly the passed bounding Rect #7535

Closed
ivan-todorov-progress opened this issue May 27, 2022 · 3 comments
Assignees
Labels
area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter partner Issue or Request from a partner team platform/android 🤖 platform/iOS 🍎 platform/macOS 🍏 macOS / Mac Catalyst platform/windows 🪟 s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@ivan-todorov-progress
Copy link

Description

Simply put, Arrange should not assume that the passed bounding Rect has the same Size as the passed size constraints on Measure. For instance, it is completely valid to call Measure with 200x100 size constraints, but then call Arrange with a 400x300 bounding Rect. The actual available Size is often not known during Measure, but is only available during Arrange.

What happens in practice is, when Measure is called on a Layout with some finite size constraints, the Layout remembers the measured size in the DesiredSize property and uses that during Arrange, disregarding the actual size passed with the bounding Rect.

Steps to Reproduce

Download an run the attached sample project.

TestApp.zip

The sample project contains a CustomLayout, which is used to demonstrate the incorrect behavior. The CustomLayout simply calls Measure and Arrange on its only child forwarding the passed parameters. The content of the CustomLayout is a Grid with a Label, which is centered inside the Grid. The CustomLayout has a bool property to control whether to pass the original size constraints when measuring the child or double.PositiveInfinity. Observe how the child Grid behaves differently on Arrange, depending on the arguments passed on Measure, even though we pass the same bounding Rect during Arrange. I have set a BacgroundColor on the Grid to demonstrate that the Grid is arranged correctly in both cases.

The following screenshot illustrates the behavior with finite size constraints on Measure (the Label is centered in the Grid):

image

The next screenshot demonstrates the behavior with infinite size constraints on Measure (the Label is not centered in the Grid):

image

Version with bug

6.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

iOS, Android, Windows, macOS

Affected platform versions

N/A

Did you find any workaround?

One semi-working workaround is to call Measure of the child during Arrange with the final size constraints. This crashes on Windows with an infinite layout loop however. ;-)

Relevant log output

No response

@ivan-todorov-progress ivan-todorov-progress added s/needs-verification Indicates that this issue needs initial verification before further triage will happen t/bug Something isn't working labels May 27, 2022
@Eilon Eilon added the area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter label May 27, 2022
@kristinx0211 kristinx0211 added s/verified Verified / Reproducible Issue ready for Engineering Triage and removed s/needs-verification Indicates that this issue needs initial verification before further triage will happen labels Jun 8, 2022
@kristinx0211
Copy link

verified repro on android with above repro project.

@hartez hartez self-assigned this Jun 8, 2022
@hartez hartez added this to the 6.0-servicing milestone Jun 8, 2022
@hartez hartez removed their assignment Aug 2, 2022
@samhouts samhouts added the partner Issue or Request from a partner team label Aug 3, 2022
@Redth Redth modified the milestones: 6.0-servicing, Backlog Aug 30, 2022
@ghost
Copy link

ghost commented Aug 30, 2022

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@Redth Redth modified the milestones: Backlog, .NET 7 Planning Aug 30, 2022
@Redth Redth modified the milestones: .NET 7 Planning, 7.0 Aug 31, 2022
@hartez
Copy link
Contributor

hartez commented Sep 15, 2022

This is now working as expected in with 6.0.400.

Screenshot_20220915-102115

@hartez hartez closed this as completed Sep 15, 2022
@Redth Redth modified the milestones: 7.0, 7.0-rc2 Oct 4, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Nov 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter partner Issue or Request from a partner team platform/android 🤖 platform/iOS 🍎 platform/macOS 🍏 macOS / Mac Catalyst platform/windows 🪟 s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants