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

[iOS] Fix for the CollectionView to prevent duplicate groups or crashes when adding a new item to a group or when adding a new group. #24873

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Tamilarasan-Paranthaman
Copy link
Contributor

Root Cause:

1. Add item in the group:

  • Dequeuing a supplementary view for measurement caused multiple instances of the header and footer to appear in the view.

2. Adding new group:

  • We checked if _collectionView.NumberOfSections() == 0 to determine whether a reload was required, in conjunction with the NotLoadedYet() condition.
  • However, using _collectionView.NumberOfSections() caused a crash when the collection view was empty and a new group was added, as NumberOfSections() == 0 is always true for an empty collection. This check prevented the adding a new group.

Description of Change:

1. Add item in the group:

  • We removed the version check and dequeuing logic to prevent the issue of duplicate header/footer templates.
  • Now, we always use MeasureSupplementaryView, which calculates the size without dequeuing the view, ensuring that the supplementary is only rendered when necessary.

2. Adding new group:

  • Modified the condition to check only if the collection view has not yet been loaded using the NotLoadedYet() method.
  • By removing the section check and focusing solely on whether the collection view has been loaded, we ensure that the data reloads properly in both empty and populated states.

Validated the behaviour in the following platforms,

  • Android
  • Windows
  • iOS
  • Mac

Issues Fixed

Fixes #17969
Fixes #20336

Screenshots

After Issue Fix

Screen.Recording.mov

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Sep 23, 2024
Copy link
Contributor

Hey there @Tamilarasan-Paranthaman! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@Tamilarasan-Paranthaman Tamilarasan-Paranthaman added platform/iOS 🍎 area-controls-collectionview CollectionView, CarouselView, IndicatorView labels Sep 23, 2024
@PureWeen
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@rmarinho
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView community ✨ Community Contribution platform/iOS 🍎
Projects
None yet
3 participants