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

Fix for CarouselView reverts to displaying 1st item in collection when collection modified #26608

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

Conversation

SuthiYuvaraj
Copy link
Contributor

Issue Details

Behavior in windows: When modifying the collection, the CarouselView scrolls to display the first item. This is the expected behavior when considering the ItemsUpdatingScrollMode.
Android and iOS: While updating the collection, ItemsUpdatingScrollMode is not respected, causing the current position to deviate from the expected behavior for keeping items in view.

Root Cause

Android: In the MauiCarouselRecyclerView, the ItemsUpdatingScrollMode is not applied during the ItemsCollectionChanged event. As a result, the CarouselView maintains the position of the previously scrolled item.
iOS and Mac: In the CarouselViewController, the collection update ignores the ItemsUpdatingScrollMode, and the current position remains unchanged, irrespective of the scroll mode settings.

Fix Details

Android: Updated the MauiCarouselRecyclerView to adjust the carousel position based on the ItemsUpdatingScrollMode during collection updates.
iOS and Mac: Incorporated the ItemsUpdatingScrollMode into the collection update logic to ensure the position is updated appropriately according to the specified scroll mode.

Issues Fixed

Fixes #25991

Output Screenshot

Before Issue Fix After Issue Fix
Screen.Recording.2024-12-12.at.8.33.19.PM.mov
Screen.Recording.2024-12-12.at.8.30.44.PM.mov

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Dec 13, 2024
@vishnumenon2684 vishnumenon2684 added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Dec 13, 2024
@SuthiYuvaraj
Copy link
Contributor Author

Hi @jsuarezruiz, We have fixed the issue. On Windows, ItemsUpdatingScrollMode is considered during collection updates. For Android and iOS, we have implemented code changes to ensure consistent behavior across all platforms and test cases for this issue are already included in the 26160 PR

@jfversluis jfversluis added the area-controls-collectionview CollectionView, CarouselView, IndicatorView label Dec 13, 2024
@SuthiYuvaraj SuthiYuvaraj marked this pull request as ready for review December 13, 2024 15:22
@SuthiYuvaraj SuthiYuvaraj requested a review from a team as a code owner December 13, 2024 15:22
if (_positionAfterUpdate == -1)
{
return;
}

_gotoPosition = -1;

var targetPosition = _positionAfterUpdate;
// We need to update the position while modifying the collection.
Copy link
Member

Choose a reason for hiding this comment

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

I think we might want for clear read refactor this on this one method ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we might want for clear read refactor this on this one method ?

Hi @rmarinho , Not clear about your concern.Are you suggesting improvements to the method's implementation itself, or are you referring to enhancing the comments we've added to this method?

// We need to update the position while modifying the collection.
if (ItemsView.ItemsUpdatingScrollMode == ItemsUpdatingScrollMode.KeepItemsInView)
{
targetPosition = 0;
Copy link
Member

Choose a reason for hiding this comment

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

won t this always scroll to the first position ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

won t this always scroll to the first position ?

Yes, based on the documentation and behavior of the Windows platform, we implemented code changes to update the scrollposition according to the ItemsUpdatingScrollMode. When ItemsUpdatingScrollMode is set to KeepItemsInView, the scroll position will adjust to the first item in view. To maintain the scrolled index, KeepScrollOffset should be used instead.

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 partner/syncfusion Issues / PR's with Syncfusion collaboration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Windows] - CarouselView reverts to displaying 1st item in collection when collection modified
5 participants