Arrange on Layouts not respecting correctly the passed bounding Rect #7535
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
Description
Simply put,
Arrange
should not assume that the passed boundingRect
has the sameSize
as the passed size constraints onMeasure
. For instance, it is completely valid to callMeasure
with 200x100 size constraints, but then callArrange
with a 400x300 boundingRect
. The actual availableSize
is often not known duringMeasure
, but is only available duringArrange
.What happens in practice is, when
Measure
is called on aLayout
with some finite size constraints, theLayout
remembers the measured size in theDesiredSize
property and uses that duringArrange
, disregarding the actual size passed with the boundingRect
.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. TheCustomLayout
simply callsMeasure
andArrange
on its only child forwarding the passed parameters. The content of theCustomLayout
is aGrid
with aLabel
, which is centered inside theGrid
. TheCustomLayout
has abool
property to control whether to pass the original size constraints when measuring the child ordouble.PositiveInfinity
. Observe how the childGrid
behaves differently onArrange
, depending on the arguments passed onMeasure
, even though we pass the same boundingRect
duringArrange
. I have set aBacgroundColor
on theGrid
to demonstrate that theGrid
is arranged correctly in both cases.The following screenshot illustrates the behavior with finite size constraints on
Measure
(theLabel
is centered in theGrid
):The next screenshot demonstrates the behavior with infinite size constraints on
Measure
(theLabel
is not centered in theGrid
):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 duringArrange
with the final size constraints. This crashes on Windows with an infinite layout loop however. ;-)Relevant log output
No response
The text was updated successfully, but these errors were encountered: