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

Ensure that Grid is treating star rows/columns as Auto when unconstrained #13999

Merged
merged 2 commits into from
Mar 17, 2023

Conversation

hartez
Copy link
Contributor

@hartez hartez commented Mar 16, 2023

Description of Change

When a Grid dimension is unconstrained (e.g., if inside a StackLayout), * rows/columns along that dimension should be treated as if they were Auto. In cases where a * exists in the unconstrained dimension and an Auto row/column exist in the alternated dimension, the layout manager could get into a situation where it never measures the views which exist entirely within the intersection of * rows and columns.

These changes correct that issue and add tests to account for the situation.

Issues Fixed

Fixes #13993

@github-actions
Copy link
Contributor

Thank you for your pull request. We are auto-formatting your source code to follow our code guidelines.

@Eilon Eilon added the area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter label Mar 16, 2023
Copy link
Member

@mandel-macaque mandel-macaque left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment, but I'm blocking for it.

Comment on lines +1006 to +1012
if (double.IsInfinity(_gridWidthConstraint) && cell.IsColumnSpanStar)
{
// Because the Grid isn't horizontally constrained, we treat * columns as Auto
return true;
}

return false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just return? no need for the if

Suggested change
if (double.IsInfinity(_gridWidthConstraint) && cell.IsColumnSpanStar)
{
// Because the Grid isn't horizontally constrained, we treat * columns as Auto
return true;
}
return false;
// Because the Grid isn't horizontally constrained, we treat * columns as Auto
return double.IsInfinity(_gridWidthConstraint) && cell.IsColumnSpanStar;

Comment on lines +1022 to +1028
if (double.IsInfinity(_gridHeightConstraint) && cell.IsRowSpanStar)
{
// Because the Grid isn't vertically constrained, we treat * rows as Auto
return true;
}

return false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Samer comment.

@hartez hartez merged commit 69b3f15 into main Mar 17, 2023
@hartez hartez deleted the fix-13993 branch March 17, 2023 15:02
@hartez hartez added the backport/suggested The PR author or issue review has suggested that the change should be backported. label Mar 17, 2023
mattleibow added a commit that referenced this pull request Mar 17, 2023
* Removed BuildTizenDefaultTemplate and just have it call RadioButton's default template since they were identical. (#13996)

* Reinstate WebView cookie functionality for Android & iOS (#13736)

* Fix iOS cookies

* Fix Android Cookies

* Update src/Core/src/Platform/iOS/MauiWKWebView.cs

Co-authored-by: Manuel de la Pena <[email protected]>

* Auto-format source code

* Update MauiWKWebView.cs

* Update src/Core/src/Platform/iOS/MauiWKWebView.cs

---------

Co-authored-by: Manuel de la Pena <[email protected]>
Co-authored-by: GitHub Actions Autoformatter <[email protected]>

* Revert 10759. Fix Button sizing using HorizontalOptions. (#14005)

* Ensure that Grid is treating star rows/columns as Auto when unconstrained (#13999)

* Ensure that Grid is treating star rows/columns as Auto when unconstrained
Fixes #13993

* Auto-format source code

---------

Co-authored-by: GitHub Actions Autoformatter <[email protected]>

* [iOS] Implement ScrollView Orientation (#13657)

* [iOS] Remove not used mapper for ContentSize

* [iOS] Implement Orientation mapping

* [Samples] Add sample page for ScrollView orientation

* Try without this

* [iOS] Move from extension to helper

* Add back removed API

* Use SetNeedsLayout to call measure of ContentView

* Cleanup

* [Android] Fix Frame Renderer to use Wrapper View correctly (#12218)

* [Android] Fix Frame to call missing mapper methods

* - fix rebase

* Auto-format source code

* - update tests and wrapper view code

* - remove code that's now generalized in ViewHandler

* - cleanup frame renderer

---------

Co-authored-by: GitHub Actions Autoformatter <[email protected]>

* [controls] fix cases a GC causes events to not fire (#13997)

As seen in #13973, some of my recent changes had a flaw:

* #13550
* #13806
* #13656

Because nothing held onto the `EventHandler` in some of these cases,
at some point a GC will prevent future events from firing.

So for example, my original attempt to test this behavior:

    [Fact]
    public async Task RectangleGeometrySubscribed()
    {
        var geometry = new RectangleGeometry();
        var visual = new VisualElement { Clip = geometry };

        bool fired = false;
        visual.PropertyChanged += (sender, e) =>
        {
            if (e.PropertyName == nameof(VisualElement.Clip))
                fired = true;
        };

        // Was missing these three lines!!!
        // await Task.Yield();
        // GC.Collect();
        // GC.WaitForPendingFinalizers();

        geometry.Rect = new Rect(1, 2, 3, 4);
        Assert.True(fired, "PropertyChanged did not fire!");
    }

In each case, I added an additional test showing the problem.

I played around with some ideas, but the simplest solution is to save
the `EventHandler` in a member field of the subscriber. Will keep
thinking of smarter ways to handle this.

I also fixed several GC-related tests that were ignored, hoping they
might help find issues in this area. My `await Task.Yield()` trick was
enough to make them pass.

* Fix tests in Release mode

In `Release` mode, a `GC.KeepAlive()` call is needed for the tests to pass.

Co-authored-by: GitHub Actions Autoformatter <[email protected]>

* [iOS] Scroll with the keyboard to not block entries and editors (#13499)

---------

Co-authored-by: dustin-wojciechowski <[email protected]>
Co-authored-by: Gerald Versluis <[email protected]>
Co-authored-by: Manuel de la Pena <[email protected]>
Co-authored-by: GitHub Actions Autoformatter <[email protected]>
Co-authored-by: Javier Suárez <[email protected]>
Co-authored-by: E.Z. Hart <[email protected]>
Co-authored-by: Rui Marinho <[email protected]>
Co-authored-by: Shane Neuville <[email protected]>
Co-authored-by: Jonathan Peppers <[email protected]>
Co-authored-by: TJ Lambert <[email protected]>
@PureWeen
Copy link
Member

/backport to net7.0

@github-actions
Copy link
Contributor

Started backporting to net7.0: https://github.com/dotnet/maui/actions/runs/4501902007

@PureWeen PureWeen added the backport/approved After some discussion or review, this PR or change was approved to be backported. label Mar 23, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Dec 13, 2023
@samhouts samhouts added the fixed-in-8.0.0-preview.3.8149 Look for this fix in 8.0.0-preview.3.8149! 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.3.8149 Look for this fix in 8.0.0-preview.3.8149!
Projects
None yet
5 participants