Fixed Button rendering overflow in StackLayout#28001
Fixed Button rendering overflow in StackLayout#28001StephaneDelcroix merged 6 commits intodotnet:inflight/currentfrom
Conversation
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
There was a problem hiding this comment.
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (2)
src/Core/src/Layouts/VerticalStackLayoutManager.cs:67
- Replacing the calculated stack height with bounds.Height may resolve the overflow issue, but please verify that this change does not adversely affect vertical layout scenarios where the child content size exceeds the provided bounds.
return new Size(bounds.Width, bounds.Height);
src/Core/src/Layouts/HorizontalStackLayoutManager.cs:76
- Directly returning the bounds for horizontal layout might resolve the current issue, but please confirm that it does not introduce regressions in cases where child elements require more width than the bounds indicate.
return new Size(bounds.Width, bounds.Height);
|
/rebase |
3158513 to
5035582
Compare
|
/rebase |
5035582 to
10caf4b
Compare
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
/rebase |
10caf4b to
66ca72f
Compare
|
/rebase |
66ca72f to
20e9bfc
Compare
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
/rebase |
6ea9999 to
3f332fd
Compare
| { | ||
| StackLayout stackLayout = new StackLayout | ||
| { | ||
| Padding = 15, |
There was a problem hiding this comment.
Can extend the sample? Extend the test to a case with asymmetric padding (e.g., Padding="15,30,20,25") and assert via geometry that the button’s rect is within the padded content box to catch regressions beyond screenshots.
There was a problem hiding this comment.
@jsuarezruiz Attempted to add an assertion verifying that the button’s layout rectangle remains within the padded content area. The test passes successfully on Android, iOS, and macOS; however, on Windows, the AutomationId does not work for layout validation.
e4240fb
into
dotnet:inflight/current
* Fixed Button rendering overflow when padding is set in StackLayout * Added test case * Modified the fix, returned bounds.Width and bounds.height * Added snapshots * Re-added Snapshot for WinUI and macOS * Resaved HorizontalScrollBarShouldHideOnNever
* Fixed Button rendering overflow when padding is set in StackLayout * Added test case * Modified the fix, returned bounds.Width and bounds.height * Added snapshots * Re-added Snapshot for WinUI and macOS * Resaved HorizontalScrollBarShouldHideOnNever
* Fixed Button rendering overflow when padding is set in StackLayout * Added test case * Modified the fix, returned bounds.Width and bounds.height * Added snapshots * Re-added Snapshot for WinUI and macOS * Resaved HorizontalScrollBarShouldHideOnNever
* Fixed Button rendering overflow when padding is set in StackLayout * Added test case * Modified the fix, returned bounds.Width and bounds.height * Added snapshots * Re-added Snapshot for WinUI and macOS * Resaved HorizontalScrollBarShouldHideOnNever
* Fixed Button rendering overflow when padding is set in StackLayout * Added test case * Modified the fix, returned bounds.Width and bounds.height * Added snapshots * Re-added Snapshot for WinUI and macOS * Resaved HorizontalScrollBarShouldHideOnNever
* Fixed Button rendering overflow when padding is set in StackLayout * Added test case * Modified the fix, returned bounds.Width and bounds.height * Added snapshots * Re-added Snapshot for WinUI and macOS * Resaved HorizontalScrollBarShouldHideOnNever
Issue Details
When a button is placed within a stack layout and a padding of 15 is applied, the button's rendering extends beyond the boundaries of the stack layout. This results in an undesirable visual overflow.
Also, when a HeightRequest and WidthRequest are provided, the StackLayout does not adhere to the specified HeightRequest in WinUI. Instead, it adjusts based on the child's height which is unexpected.
Root Cause
In the VerticalStackLayoutManager.cs, the actual value returned from ArrangeChildren() includes padding only for the top, while the calculated value does not account for the left, right and bottom padding. This discrepancy results in button overflow within the StackLayout.
Description of Change
Implemented a fix that ensures the bounds.Width and bounds.Height values are returned, properly accounting for the right and bottom padding in the layout calculation. This update accurately incorporates all padding values, resolving the overflow issue effectively.
Validated the behaviour in the following platforms
Issues Fixed:
Fixes #22075
Fixes #29826
Screenshots