[Android] Fix CarouselView Issue29216 test regression on candidate branch#35041
Merged
kubaflo merged 1 commit intodotnet:inflight/candidatefrom Apr 21, 2026
Merged
Conversation
Contributor
|
/azp run maui-pr-uitests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
This was referenced Apr 20, 2026
Open
kubaflo
approved these changes
Apr 21, 2026
Ahamed-Ali
pushed a commit
that referenced
this pull request
Apr 22, 2026
…ranch (#35041) <!-- Please let the below note in for people that find this PR --> > [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Root Cause During CarouselView startup, `UpdateFromPosition` triggers an initial animated scroll to center the first item. In this flow, `_gotoPosition` is set, but `CarouselViewScrolled` exits early (`!_initialized`), so `UpdatePosition` never clears it. This leaves `_gotoPosition` stuck at `0`, blocking subsequent programmatic scrolls. When `Position = 1` is later set (Issue29216), the guard condition (`_gotoPosition == -1`) fails, preventing the scroll. ### Description of Change Updated the animated scroll path to assign `_gotoPosition` only after initialization. This aligns it with the non-animated fix - [34996](#34996), preserves startup centering behavior, and ensures `_gotoPosition` is set only when it can be properly cleared. ### Issues Fixed Fixes regression introduced by #34570 : `Issue29216CarouselViewScrollingIssue on Candidate branch`. Tested the behaviour in the following platforms - [x] Android - [ ] Windows - [ ] iOS - [ ] Mac
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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!
Root Cause
During CarouselView startup,
UpdateFromPositiontriggers an initial animated scroll to center the first item. In this flow,_gotoPositionis set, butCarouselViewScrolledexits early (!_initialized), soUpdatePositionnever clears it. This leaves_gotoPositionstuck at0, blocking subsequent programmatic scrolls.When
Position = 1is later set (Issue29216), the guard condition (_gotoPosition == -1) fails, preventing the scroll.Description of Change
Updated the animated scroll path to assign
_gotoPositiononly after initialization.This aligns it with the non-animated fix - 34996, preserves startup centering behavior, and ensures
_gotoPositionis set only when it can be properly cleared.Issues Fixed
Fixes regression introduced by #34570 :
Issue29216CarouselViewScrollingIssue on Candidate branch.Tested the behaviour in the following platforms