-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Make layout honor MaxWidth and MaxHeight requests #15022
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
If Width is not explicitly set but MaximumWidth is, we should still use that as part of the arranging calculations
jknaudt21
added
the
area-layout
StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter
label
May 10, 2023
Thank you for your pull request. We are auto-formatting your source code to follow our code guidelines. |
hartez
approved these changes
May 10, 2023
mattleibow
approved these changes
May 11, 2023
mattleibow
added
the
backport/suggested
The PR author or issue review has suggested that the change should be backported.
label
May 11, 2023
rmarinho
pushed a commit
that referenced
this pull request
May 30, 2023
* Ensure MaximumWidth is used when arranging If Width is not explicitly set but MaximumWidth is, we should still use that as part of the arranging calculations * Account for alignment * Add tests * Auto-format source code --------- Co-authored-by: GitHub Actions Autoformatter <autoformat@example.com>
hartez
added
the
backport/approved
After some discussion or review, this PR or change was approved to be backported.
label
May 31, 2023
/backport to net7.0 |
Started backporting to net7.0: https://github.com/dotnet/maui/actions/runs/5138858004 |
Awesome fix! Found a bug though, see #15785 |
samhouts
added
the
fixed-in-8.0.0-preview.5.8529
Look for this fix in 8.0.0-preview.5.8529!
label
Aug 2, 2024
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
backport/approved
After some discussion or review, this PR or change was approved to be backported.
backport/suggested
The PR author or issue review has suggested that the change should be backported.
fixed-in-8.0.0-preview.5.8529
Look for this fix in 8.0.0-preview.5.8529!
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of Change
Layouts were not taking into account a view's MaxWidth/Height if the layout's alignment policy was set to
Fill
. This caused the frustrating behavior that you would specify an element's MaxWidth/Height but have these values completely ignored.The fix consists on making the
ComputeFrame
method and theAlignHorizontal
/AlignVertical
methods to take into account these properties. The changes can be summarized as follows:If an element has an unset
WidthRequest
but has aMaximumWidthRequest
, then its consumed width should be the minimum between the MaximumWidthRequest and the available space (i.ebounds.Width
). This type of logic should also be used in the alignment calculations iff theWidthRequest
is not set.Below are screenshots of the before and after of running this code on different platforms:
Notice how the buttons are now smaller and obey their MaximumWidthRequests.
Las but not least, some of the existing unit tests were modified to take into account MaximumWidth/Height since the substitutes would return 0 for these values. I've also added tests to ensure that layouts behave as expected when the Width and Height are not set but their Maximum counterparts are.
Issues Fixed
Fixes #15002