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
[Bug] Fix Grid cells not honoring MaxWidth #16215
Conversation
The key was in the view handlers, where we weren't doing the proper handling for MaximumWidth
The problem belongs more to device tests
Hello Guys, Thanks for the fix, but please merge this fix to the .Net 7 version as well. Please consider copying the three lines of code to the .Net7 version. Kind Regards, FYI: using preview versions (like for .Net8) for production releases is really a no-go for us :-( |
/backport to net7.0 |
Started backporting to net7.0: https://github.com/dotnet/maui/actions/runs/5880806564 |
@hartez backporting to net7.0 failed, the patch most likely resulted in conflicts: $ git am --3way --ignore-whitespace --keep-non-patch changes.patch
Applying: Make Grid be constrained by MaxWidth
Applying: Ensure grid cells honor max width/height
Applying: Attempt to (unsuccessfully) add tests
Applying: Fix typo
Applying: Fix bug, revert wrong changes
Using index info to reconstruct a base tree...
M src/Core/src/Handlers/ViewHandlerExtensions.iOS.cs
M src/Core/src/Layouts/GridLayoutManager.cs
M src/Core/src/Platform/Android/ContextExtensions.cs
Falling back to patching base and 3-way merge...
Auto-merging src/Core/src/Platform/Android/ContextExtensions.cs
Auto-merging src/Core/src/Layouts/GridLayoutManager.cs
Auto-merging src/Core/src/Handlers/ViewHandlerExtensions.iOS.cs
CONFLICT (content): Merge conflict in src/Core/src/Handlers/ViewHandlerExtensions.iOS.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0005 Fix bug, revert wrong changes
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128 Please backport manually! |
@hartez an error occurred while backporting to net7.0, please check the run log for details! Error: git am failed, most likely due to a merge conflict. |
Problem
When computing the size of a cell, Grid would run into trouble depending on the platform when given MaxWidth.
On Android, the grid's children would often look at the screen's max width (even if that meant looking at the wrong orientation) and ignore the dimensions passed to the grid object.
On iOS, the grid's children would compute their width when
SizeThatFits
was called. This call was done without taking into account MaxWidthSolution
When calculating the dimension constraints for a view, we take into account the MaxWidth and MaxHeight as long as they are smaller than the already established constraints.
Issues Fixed
Fixes #15785
Fixes #7366
Remaining Work