Skip to content

[Android] Fix for the CarouselView doesn't scroll to the right Position after changing the ItemSource with Loop enabled#24160

Closed
Ahamed-Ali wants to merge 5 commits intodotnet:mainfrom
Ahamed-Ali:fix-17283
Closed

[Android] Fix for the CarouselView doesn't scroll to the right Position after changing the ItemSource with Loop enabled#24160
Ahamed-Ali wants to merge 5 commits intodotnet:mainfrom
Ahamed-Ali:fix-17283

Conversation

@Ahamed-Ali
Copy link
Copy Markdown
Contributor

@Ahamed-Ali Ahamed-Ali commented Aug 12, 2024

Root Cause

When reloading the ItemSource, the CurrentItem was set to null in the UpdateAdapter, which caused the UpdateInitialPosition method to miss calculating the itemCount based on the CurrentItem. As a result, the LoopScale value was incorrect in the LoopedPosition method, causing centerPosition to be set to 0 in the GetGoToIndex method of the CarouselViewLoopManager class. This led to a negative index position in the GetGoToIndex and prevented scrolling.

Description of change

Updated the ItemCount based on the carousel loop, position, and ItemSource, ensuring the proper calculation of ItemCount, which helps maintain the correct looped position when reloading the items

Issue Fixed

Fixes #17283

Before Fix

CarouselWithIssue.mp4

After Fix

CarouselLoopafterfix.mp4

@Ahamed-Ali Ahamed-Ali requested a review from a team as a code owner August 12, 2024 15:06
@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Aug 12, 2024
@jfversluis
Copy link
Copy Markdown
Member

jfversluis commented Aug 12, 2024

/azp run

@azure-pipelines

This comment was marked as outdated.

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@Ahamed-Ali Ahamed-Ali marked this pull request as draft August 13, 2024 05:38
@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).


[Test]
[Category(UITestCategories.CarouselView)]
public void Issue17283Test()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Give the test a more significant name indicating what's being tested here.
This is the name that shows up in the test results so it's easier if it has a valid description

@Ahamed-Ali
Copy link
Copy Markdown
Contributor Author

Closing this due to duplicate PR created - #24431

@Ahamed-Ali Ahamed-Ali closed this Aug 26, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Sep 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

community ✨ Community Contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Android] CarouselView doesn't scroll to the right Position after changing the ItemSource with Loop enabled

3 participants