[Android] Fix for the CarouselView doesn't scroll to the right Position after changing the ItemSource with Loop enabled.#24431
Conversation
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
Azure Pipelines successfully started running 3 pipeline(s). |
| @@ -0,0 +1,27 @@ | |||
| #if ANDROID | |||
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
PureWeen
left a comment
There was a problem hiding this comment.
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 successfully started running 3 pipeline(s). |
|
Root Cause
When reloading the ItemSource, the
CurrentItemwas set to null in theUpdateAdapter, which caused theUpdateInitialPositionmethod to miss calculating theitemCountbased on theCurrentItem. As a result, theLoopScalevalue was incorrect in theLoopedPositionmethod, causingcenterPositionto be set to 0 in theGetGoToIndexmethod of the CarouselViewLoopManager class. This led to a negative index position in theGetGoToIndexand 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