Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug] Items in grouped CollectionView not positioned correctly on iOS #10436

Closed
cristiproj opened this issue Apr 24, 2020 · 12 comments
Closed

[Bug] Items in grouped CollectionView not positioned correctly on iOS #10436

cristiproj opened this issue Apr 24, 2020 · 12 comments
Labels
a/collectionview i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often p/iOS 🍎 t/bug 🐛

Comments

@cristiproj
Copy link

cristiproj commented Apr 24, 2020

Description

I am using grouped CollectionView with GridItemsLayout, with a span of 4.
The first time the page is loaded all the items are on the first column (screenshot 1). After trying to scroll, all the items are rearranged in the 4 column layout. But, the first element is incorrectly (screenshot 2).
The issue only happens on iOS. I tested in the simulator:

  • iOS version: 12.2 everything is ok
  • iOS version: 13.4 the broken behavior can be observed

Steps to Reproduce

  1. Create grouped CollectionView with griditemlayout
  2. Bind to observablecollection / list
  3. The behavior described can be observed

Expected Behavior

The items are displayed correctly in the groupings according to the settings in the griditemlayout. With no awkward spaces.

Actual Behavior

The items are not displayed correctly, not when the page is first loaded and not when scrolling

Basic Information

  • Version with issue: 4.4.0.991265, 4.5.0.530 and 4.5.0.657
  • Last known good version: -
  • IDE: Visual Studio Community 2019 for Mac, Version 8.5.4 (build 12)
  • Platform Target Frameworks:
    • iOS: 13.4
    • Android: 9.0
  • Android Support Library Version:
  • Nuget Packages:
  • Affected Devices:

Screenshots

Screenshot 1
image
Screenshot 2
image

Reproduction Link

https://github.com/cristiproj/collectionviewissue

Workaround

I have found found a possible workaround in using a listview with a datatemplate containting a flexlayout. Unfortunately, the items in the flexlayout are not arranged as nicely as in the collectionview. A small sample project can be found here: https://github.com/cristiproj/ListViewScheduleTest.

I think, another possible workaround would be by using a custom layout, but I did not look at it.

@jsuarezruiz
Copy link
Contributor

@cristiproj Thanks for the reproduction sample.

@jsuarezruiz jsuarezruiz added the i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often label Apr 24, 2020
@jsuarezruiz jsuarezruiz removed the s/unverified New report that has yet to be verified label Apr 24, 2020
@znelson32
Copy link

znelson32 commented Apr 27, 2020

Same problem here, but my scenario is more simple. I have a grouped list of items with a GridItemsLayout. When I add Span="2" to get nice 2x2 boxes, the rendering is all screwed up. The items render over top of each other and jump around when scrolling.

I can't roll back past 4.5.0.356 to see when this bug was introduced because I need the new FontExport stuff. But I confirmed this bug exists in the latest beta available (4.6.0.616-pre4)

@cristiproj
Copy link
Author

I think the bug is also related to the iOS version. As I wrote in the issue, on iOS 12.2 the collectionview is rendered correctly, but not on 13.4.

@cristiproj
Copy link
Author

A possible workaround is using a listview and flexlayout for the child items. Small sample project for testing: https://github.com/cristiproj/ListViewScheduleTest.

@znelson32
Copy link

Thank you, @cristiproj !

@kramer-e
Copy link

kramer-e commented Jun 5, 2020

I have the same issue on the iPhone 8 emulator (iOS13.5) with a CollectionView that has a vertical GridItemsLayout with a span of 2. The items are stacked and glitched and move while scrolling. Issue #8738, #9000 from last year and #10971, #11011 from last week also describe a similar issue. Please give these grouping issues with the CollectionView some priority, I have opened issue #8383 in November last year and it is still not fixed.

@samhouts samhouts added this to the 5.0.0 milestone Aug 13, 2020
@jeffdevalmeida
Copy link

jeffdevalmeida commented Oct 29, 2020

I have the same problem.
My code dont work in iPhone 11 and iPhone 12. Just in iPhone 8 and 8 Plus.

I tryied to use CollectionView then list my power bi reports. See this sample at iPhone 8 Plus (iOS 14.1):
image

But in iPhone 11 and 12, my list dont work. See this sample at iPhone 11 (iOS 14.1):
image

After some analysis i found a possible solution for this case. I perceive that my tests is using the objects with same properties.
image

I changed the properties... Now it's work!
New code with properties:
image

Working at iPhone 11 (iOS 14.1)
image

XAML Code:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             Title="{Binding Title}"
             x:Class="Views.RelatoriosView"
             NavigationPage.HasBackButton="False">
    <StackLayout>
        <RefreshView IsRefreshing="{Binding IsBusy}" Command="{Binding LoadReportsCommand}">
            <StackLayout>
                <Label Margin="10,20,10,20"
                           Text=""
                           FontSize="Title"
                           FontAttributes="Bold"
                           HorizontalTextAlignment="Center"
                           VerticalTextAlignment="Center"/>
                <CollectionView x:Name="ReportsCollectionView" ItemsSource="{Binding Reports}" SelectionMode="Single" SelectedItem="{Binding SelectedReport}">
                    <CollectionView.ItemsLayout>
                        <GridItemsLayout Orientation="Vertical" Span="3"/>
                    </CollectionView.ItemsLayout>
                    <CollectionView.ItemTemplate>
                        <DataTemplate>
                            <Grid Padding="5">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="100" />
                                </Grid.RowDefinitions>
                                <Image Grid.Row="0"
                                   Source="{Binding Icon}"/>
                                <Label Grid.Row="1"
                                   Text="{Binding Title}" 
                                   FontAttributes="Bold"
                                   HorizontalOptions="Center"
                                   LineBreakMode="TailTruncation" />
                            </Grid>
                        </DataTemplate>
                    </CollectionView.ItemTemplate>
                </CollectionView>
            </StackLayout>
        </RefreshView>
        <Image Aspect="AspectFit" Source="mWJYrXW.png"/>
    </StackLayout>
</ContentPage>

@samhouts samhouts removed this from the 5.0.0 milestone Nov 2, 2020
@demoh2019
Copy link

demoh2019 commented Feb 6, 2021

any Update?

@demoh2019
Copy link

demoh2019 commented Feb 7, 2021

@kramer-e

found a solution?

@kramer-e
Copy link

kramer-e commented Feb 8, 2021

No, but I've noticed that the issue doesn't appear with a span of 2 in the latest iOS + X.Forms version, maybe that was fixed in the new iOS version. The issue is still present with a span of 3 or more, along with other issues with grouping. I've used a workaround by binding to a 2 dimensional array with a single column CollectionView, but that involves duplicate code and hurts performance.

Since this is an officially supported feature of the CollectionView, I thought this would be fixed in the X.Forms 5.0 release, but all the issues are still open unfortunately. I hope the Forms team can confirm that the grouping issues can be fixed in a service release this year.

@tranb3r
Copy link

tranb3r commented Oct 5, 2021

I've just tested this issue.
I confirm the issue on the repro project (with a span of 4).
After updating XF to the latest version (5.0.0.2125), the issue is gone.
@jfversluis I think you can close this ticket.

@jfversluis
Copy link
Member

Awesomesauce! Thank you so much!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a/collectionview i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often p/iOS 🍎 t/bug 🐛
Projects
None yet
Development

No branches or pull requests

9 participants