-
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
Grouped CollectionView content/items overlaps on iOS when data changes or when pull to refresh data #20336
Comments
@nsood9 I have seen a samilar issue. In my case the Group Headers wouldnt be removed when I clear my ItemsSource, then causing overlaps between old group headers and the new items/ headers. |
Hi @nsood9. We have added the "s/try-latest-version" label to this issue, which indicates that we'd like you to try and reproduce this issue on the latest available public version. This can happen because we think that this issue was fixed in a version that has just been released, or the information provided by you indicates that you might be working with an older version. You can install the latest version by installing the latest Visual Studio (Preview) with the .NET MAUI workload installed. If the issue still persists, please let us know with any additional details and ideally a reproduction project provided through a GitHub repository. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
I'm also facing the exact same issue apart from the one I've created a bug for. The group headers are not removing even when the ItemSource is null or I clear it manually, the group headers are always sticking to the view no matter what and then overlaps with the new/actual header and items. I didn't understand the way you've suggested to handle this case. Can you please explain it with an example, because my data structure is: I have 3-4 types of data to show in the CollectionView using DataTemplateSelector based on their types and a DateTime property is the grouping factor based on which I've grouped the collection and displaying them as group of items under different Dates as header. |
@jsuarezruiz I'm using the latest MAUI version for both android and iOS and this issue still persists. |
Something like this:
|
@borrmann Thank you for sharing the logic, I need to give it a try with the type of data and UI requirement I have in my project. But instead of any workaround, is there any fix available for the existing Grouped CollectionView overlapping issue? MAUI team should fix this issue as it a major UI bug faced by number of people working with MAUI, but it is a very basic requirement of any app to be able to display grouped collection data without any cosmetic problems. |
@jamesmontemagno @jonathanpeppers Are we planning to fix this overlapping issue for Grouped Collectionview in the upcoming release as this is a very basic requirement for any app to be able to use a grouped CollectionView to show grouped data. At this point the list in my app is not that big, it just contains 5-10 records at a time, still the UI looks so bad because of this overlapping issue, every text and cell just overlaps on each other. But as the user base grows, the data/records will also grow and I wonder how disastrous a simple grouped CollectionView UI will look then. Can we please prioritize this issue for the upcoming release as it's a basic UI control and working with MAUI for an app, one should be able to use at least the basic controls without these UI bugs. |
@jsuarezruiz , this appears to still be an issue in the latest release of Maui 8.0.7 (as of today). |
I can confirm seeing this issue only on iOS (Android and Windows are fine) on 8.0.7 |
Still there's no fix or discussion to fix this issue by anyone. That's quite disappointing! |
Blocking me. I'm seeing this on the iOS version of my net Maui app. Grouped collectionview inside refreshview. Happens in about half of my scenarios when user chooses to refresh. I've found no workaround (no way to reset the collectionview, other than recreating the element.) |
We are also suffering massively from this issue. It is causing a delay in releasing our software. Is there a workaround or has this been prioritized. Grouped collections are a basic function in my opinion. |
@Uridel I have posted a workaround above. I am using that everywhere where I need Grouped Collections and it works fine. |
@borrmann It isn't really a viable options as our application is rather large. It would mean changing ~100 Grouped collectionviews. Some of which have varying complexities of the way I view data. While I commend you for the solution, i also wonder what the impact on performance will be. Nevertheless this is an issue the Maui teams must fix. |
Hey Rob .. wonder if you can add me to the repo so I can take a look. Thanks |
@rmarinho , I could not recreate this issue today no matter what I tried. If I do find a scenario that triggers it, I'll create a sample repo and tag you. |
Sorry for the delay. Thanks for looking. You have been invited to https://github.com/bogle-tools/retiremaze now. Tab 2, 4, and 5 are the ones that used grouped collectionviews. tab 5 is the one that shows the problem (duplicated/dead headers when scrolling and/or doing a refresh operation. Tab 3 is using a fake grouping...not collectionview grouping. Update: related/different issue; the refresh view also scrolls content down a bit instead of staying at the top. |
Sorry, I didn't get it. I'm using the latest MAUI version for my app and still facing this issue. The grouped collection view does gets distorted on iOS, specially if we use pull to refresh view and user pulls to refresh data, all of the cells/records and their group headings overlap each other. And even when the data is being loaded the empty list keep displaying the old group headings which it shouldn't display. I didn't get what do you mean by "file new maui app"? |
Running into similar problems after applying workarounds (this and this one) for crashes on iOS: #10163, #18481, #20037. Haven't yet come across a workaround that consistently works for these invalid sized/overlapping items. Honestly, I can't believe how some of the most basic UI components (both listview and collectionview) are so broken beyond repair. Really hope someone is able to pinpoint where these issues come from. |
We have same problem. Different item hights in grouped CollectionView on iOS makes overlapping group headers over items. We are forced to use fixed heights. Really bad.... |
@filipleifer Facing the same issue for the |
@nsood9 i am also facing same issue. did you fixed this issue? |
The overlap issue I had with the CollectionView on iOS is that when initially populated it was fine but when I applied a filter, scrolled down the list and then removed the filter I would see an overlap, as in the screenshot below: The fix, for me at least, was to scroll to the top of the CollectionView first in code and then update the CollectionView.
I'm using MVVM, so I had to send a message from the ViewModel (via WeakReferenceMessenger) which the View(Page) picked up. To test, manually scroll to the start of the list and make your changes to see if that fix will work for you. I hope this helps. |
I've solved the problem with this code handlers.AddHandler<CollectionView, CollectionViewHandlerEx>();
CollectionViewHandler.Mapper.ModifyMapping(nameof(CollectionView.ItemsSource), MapItemsSource);
private static void MapItemsSource(CollectionViewHandler handler, CollectionView view, Action<IElementHandler, IElement>? existingMapper)
{
// ISSUE: for grouped CollectionView, content overlaps after changes to ItemsSource or collection
// https://github.com/dotnet/maui/issues/20336
if (view.IsGrouped && handler.PlatformView.Subviews is [UICollectionView collectionView])
{
collectionView.ClearSubviews();
}
var oldItemsSource = view.ItemsSource;
// run existing mapper
if (existingMapper is not null)
{
existingMapper(handler, view);
}
var newItemsSource = view.ItemsSource;
// listen to collection changes and run fix when collection is reset
if (handler is not CollectionViewHandlerEx collectionViewHandler)
{
return;
}
if (oldItemsSource is INotifyCollectionChanged oldNotifyCollectionChanged)
{
oldNotifyCollectionChanged.CollectionChanged -= collectionViewHandler.NotifyCollectionChanged_CollectionChanged;
}
if (newItemsSource is INotifyCollectionChanged newNotifyCollectionChanged)
{
newNotifyCollectionChanged.CollectionChanged += collectionViewHandler.NotifyCollectionChanged_CollectionChanged;
}
}
internal sealed class CollectionViewHandlerEx : CollectionViewHandler
{
internal void NotifyCollectionChanged_CollectionChanged(object? _, NotifyCollectionChangedEventArgs e)
{
if (e.Action is not NotifyCollectionChangedAction.Reset)
{
return;
}
// ISSUE: for grouped CollectionView, content overlaps after changes to ItemsSource or collection
// https://github.com/dotnet/maui/issues/20336
if (VirtualView is CollectionView { IsGrouped: true } && PlatformView.Subviews is [UICollectionView collectionView])
{
collectionView.ClearSubviews();
}
}
} |
Description
On iOS when CollectionView is used to display grouped data, the content items displayed in the CollectionView overlaps. For the first time it calculates the size correctly and shows everything as expected, but if sometimes, the list data changes or I pull to refresh new data (using RefreshView), the collection content is overlapping and looks so ugly.
Steps to Reproduce
Create a new MAUI app project using usual VS for Mac
Create ObservableCollection for grouped data:
[ObservableProperty]
ObservableCollection<IGrouping<DateTime?, Items>> groupedItems;
Populate the data from API or your data model
Design your layout to include CollectionView with DataTemplateSelector:
Run in iOS simulator, it will look good the very first time and then if you pull to refresh the data, observe the bad overlapping.
Data is dynamic, it will sometimes overlap if the data is changed during runtime and some of the data templates are now not available as per the data
I cannot use ItemSizingStrategy="MeasureFirstItem" because, my design list design requires different data templates, which are of complete different sizes, so there is no chance I can use MeasureFirstItem ItemSizingStrategy.
Due to this, the UI for the very first screen of my app looks so bad that it's not possible to release or at least demo it to client.
Link to public reproduction project repository
No response
Version with bug
8.0.3
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
iOS
Affected platform versions
iOS 17+
Did you find any workaround?
Couldn't find any workaround yet.
Relevant log output
No response
The text was updated successfully, but these errors were encountered: