Skip to content

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

Merged
PureWeen merged 5 commits intodotnet:mainfrom
Tamilarasan-Paranthaman:fix-17283
Aug 28, 2024
Merged

[Android] Fix for the CarouselView doesn't scroll to the right Position after changing the ItemSource with Loop enabled.#24431
PureWeen merged 5 commits intodotnet:mainfrom
Tamilarasan-Paranthaman:fix-17283

Conversation

@Tamilarasan-Paranthaman
Copy link
Copy Markdown
Member

@Tamilarasan-Paranthaman Tamilarasan-Paranthaman commented Aug 26, 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 and position, ensuring proper calculations to maintain the correct looped position value when reloading the items.

Issue Fixed

Fixes #17283

Before Fix

CarouselWithIssue.mp4

After Fix

CarouselLoopafterfix.mp4

@rmarinho
Copy link
Copy Markdown
Member

rmarinho commented Aug 26, 2024

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@Tamilarasan-Paranthaman Tamilarasan-Paranthaman marked this pull request as ready for review August 26, 2024 14:51
@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@@ -0,0 +1,27 @@
#if ANDROID
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.

Does it make sense to run this test on iOS and WinUI as well?

We typically let these tests run on all platforms even if the original issue is only happening on Android. This also lets us make sure that we have consistent behavior between all platforms.

If it's broken on iOS and/or WinUI then log a bug and make a note of the bug inside this test.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Okay, I have modified the script to run the test on both iOS and WinUI. Could you please take a look and let me know?

@rmarinho
Copy link
Copy Markdown
Member

rmarinho commented Aug 27, 2024

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

Copy link
Copy Markdown
Member

@PureWeen PureWeen left a comment

Choose a reason for hiding this comment

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

it looks like windows is crashing

Just ignore windows and log an issue and then we'll be able to merge this one!

@samhouts samhouts added the area-controls-collectionview CollectionView, CarouselView, IndicatorView label Aug 27, 2024
@Tamilarasan-Paranthaman
Copy link
Copy Markdown
Member Author

it looks like windows is crashing

Just ignore windows and log an issue and then we'll be able to merge this one!

I have created a bug report for the CarouselView issue on Windows and added a note in the test. Could you please take a look into it ?

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen
Copy link
Copy Markdown
Member

  • Failing test is unrelated

@PureWeen PureWeen merged commit 84a6544 into dotnet:main Aug 28, 2024
@samhouts samhouts added fixed-in-net9.0-nightly This may be available in a nightly release! fixed-in-net8.0-nightly This may be available in a nightly release! labels Sep 5, 2024
@samhouts samhouts added fixed-in-9.0.0-rc.2.24503.2 and removed fixed-in-net9.0-nightly This may be available in a nightly release! labels Oct 14, 2024
@samhouts samhouts removed the fixed-in-net8.0-nightly This may be available in a nightly release! label Oct 14, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Nov 16, 2024
@sheiksyedm sheiksyedm added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Dec 6, 2024
@Tamilarasan-Paranthaman Tamilarasan-Paranthaman deleted the fix-17283 branch June 16, 2025 10:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-controls-collectionview CollectionView, CarouselView, IndicatorView community ✨ Community Contribution fixed-in-9.0.0-rc.2.24503.2 partner/syncfusion Issues / PR's with Syncfusion collaboration

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

6 participants