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

CollectionView with GridItemsLayout: Issues when changing Span #8387

Closed
Forestbrook opened this issue Jun 28, 2022 · 5 comments · Fixed by #13137
Closed

CollectionView with GridItemsLayout: Issues when changing Span #8387

Forestbrook opened this issue Jun 28, 2022 · 5 comments · Fixed by #13137
Assignees
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter fixed-in-7.0.92 Look for this fix in 7.0.92! fixed-in-7.0.100 fixed-in-7.0.101 fixed-in-8.0.0-preview.3.8149 Look for this fix in 8.0.0-preview.3.8149! p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint partner/cat 😻 this is an issue that impacts one of our partners or a customer our advisory team is engaged with platform/iOS 🍎 platform/windows 🪟 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working

Comments

@Forestbrook
Copy link

Description

I have a CollectionView with a GridItemsLayout. Depending on the available size I want to show more (landscape view) or less (portrait view) items on a row.

In the SizeChanged event I compute and set the right Span.

  • On iOS: crash with NullReferenceException: CollectionView is null in GridViewLayout.HandlePropertyChanged().
  • On Windows: Number of items on the row is NOT changed.
  • On Android: When I add a short delay before changing Span it seems to work correct.

Steps to Reproduce

See example project MauiGridItemsLayoutChangeSpanIssue

In the AppShell Flyout you can select two views:

  • CollectionView with workaround and
  • CollectionView with bug

Rotate the phone/tablet to see the number of items on a row change.

Version with bug

6.0.400 (current)

Last version that worked well

Unknown/Other

Affected platforms

iOS, Windows

Affected platform versions

iOS 15.5, Windows 10.0.19044

Did you find any workaround?

For iOS I found a workaround by adding a check for CollectionView==null in GridViewLayout.HandlePropertyChanged(). See GridViewLayoutExt in the example project. This works, because HandlePropertyChanged() for the Span property is called again when CollectionView is not null anymore, which is kinda weird.

For Windows I did not look for a workaround yet.

Relevant log output

No response

@Forestbrook Forestbrook added s/needs-verification Indicates that this issue needs initial verification before further triage will happen t/bug Something isn't working labels Jun 28, 2022
@Eilon Eilon added the area-controls-collectionview CollectionView, CarouselView, IndicatorView label Jun 28, 2022
@rachelkang rachelkang added platform/windows 🪟 area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter platform/iOS 🍎 fatal and removed s/needs-verification Indicates that this issue needs initial verification before further triage will happen labels Jun 28, 2022
@rachelkang rachelkang modified the milestone: 6.0-servicing Jun 28, 2022
@GalaxiaGuy
Copy link
Contributor

GalaxiaGuy commented Jun 29, 2022

This currently happens to me in Forms too (oddly enough I haven't reported a bug for it, but the comment I left in my code makes me think it's the same issue):

// Trying to set the Span on the existing gridLayout sometimes throws a NullReferenceException from deep within Forms

A workaround that worked for me is to create a new GridItemsLayout with the new Span value.

@kristinx0211 kristinx0211 added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Jun 29, 2022
@kristinx0211
Copy link

verified repro on IOS15.4 and windows with above project.

@rachelkang rachelkang added this to the 6.0-servicing milestone Jun 29, 2022
@samhouts samhouts added the p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint label Jul 12, 2022
@hartez hartez removed the fatal label Aug 1, 2022
@Redth Redth modified the milestones: 6.0-servicing, Backlog Aug 30, 2022
@ghost
Copy link

ghost commented Aug 30, 2022

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@BenderNK
Copy link

BenderNK commented Nov 20, 2022

Provided work-around does not work in Windows.

A workaround that worked for me is to create a new GridItemsLayout with the new Span value.

Specifically this:

var newSpanValue = 5
MyCollectionView.ItemsLayout = new GridItemsLayout(span: newSpanValue, ItemsLayoutOrientation.Vertical);

Neither this:

if (MyCollectionView.ItemsLayout is GridItemsLayout gridItemsLayout)
{
    var newSpanValue = 5
    gridItemsLayout.Span = newSpanValue ;
}

Nothing ever happens. Original span value that was provided in the XAML is only being respected. Also this open issue appears to be related.

@hartez
Copy link
Contributor

hartez commented Jan 23, 2023

See also: #10144.

@samhouts samhouts added the fixed-in-8.0.0-preview.3.8149 Look for this fix in 8.0.0-preview.3.8149! label Apr 12, 2023
@ghost ghost locked as resolved and limited conversation to collaborators May 12, 2023
@mikeparker104 mikeparker104 added the partner/cat 😻 this is an issue that impacts one of our partners or a customer our advisory team is engaged with label May 24, 2023
@samhouts samhouts modified the milestones: .NET 8 Planning, .NET 8 Jul 28, 2023
@samhouts samhouts added the fixed-in-7.0.92 Look for this fix in 7.0.92! label Aug 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter fixed-in-7.0.92 Look for this fix in 7.0.92! fixed-in-7.0.100 fixed-in-7.0.101 fixed-in-8.0.0-preview.3.8149 Look for this fix in 8.0.0-preview.3.8149! p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint partner/cat 😻 this is an issue that impacts one of our partners or a customer our advisory team is engaged with platform/iOS 🍎 platform/windows 🪟 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.