[Android] CarouselView: Fix scroll to last item after data reset in loop mode#31672
[Android] CarouselView: Fix scroll to last item after data reset in loop mode#31672SyedAbdulAzeemSF4852 wants to merge 4 commits intodotnet:mainfrom
Conversation
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
There was a problem hiding this comment.
Pull Request Overview
Fixes incorrect centering/scrolling behavior of CarouselView (loop mode) on Android after the ItemsSource is reset and CurrentItem points to a tail item.
Key changes:
- Adjusted loop index calculation in GetGoToIndex to use modular arithmetic and added bounds/empty checks.
- Added UpdateLoopCentering helper and invoked it after collection changes and during initial position setup when looping.
- Added a new UI test (Issue23023) and corresponding host page to reproduce and validate the scenario.
Reviewed Changes
Copilot reviewed 4 out of 7 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/Controls/src/Core/Handlers/Items/Android/CarouselViewLoopManager.cs | Corrects loop navigation index calculations and adds input validation. |
| src/Controls/src/Core/Handlers/Items/Android/MauiCarouselRecyclerView.cs | Introduces UpdateLoopCentering to properly center after resets and refactors initial positioning logic. |
| src/Controls/tests/TestCases.HostApp/Issues/Issue23023.cs | Adds a repro page with looping CarouselView and controls to reload items and scroll to last item. |
| src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue23023.cs | Adds UI test exercising reload + scroll-to-last-item scenario (currently wrapped in a conditional compilation symbol). |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
…ata reset despite CurrentItem being updated
…ing snapshot for the Mac platform
3d669d3 to
82ec14c
Compare
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 31672Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 31672" |
|
Addressed concerns raised in the AI summary. |
@kubaflo , I checked the test locally — it passes with the fix and fails without it. I’ve added the test output below for your reference.
|
|
/azp run maui-pr-uitests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run maui-pr-uitests , maui-pr-devicetests |
|
Azure Pipelines successfully started running 2 pipeline(s). |
🧪 UI Test Results🧪
|


Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Issue Details :
Root Cause:
Description of Change
Issues Fixed
Fixes #23023
Validated the behaviour in the following platforms
Output
Before.mov
After.mov