Skip to content

[Android] Fix CarouselView Issue23291 and Issue29216 test regression on candidate branch#34996

Merged
kubaflo merged 3 commits intodotnet:inflight/candidatefrom
praveenkumarkarunanithi:Fix-29544-Android
Apr 17, 2026
Merged

[Android] Fix CarouselView Issue23291 and Issue29216 test regression on candidate branch#34996
kubaflo merged 3 commits intodotnet:inflight/candidatefrom
praveenkumarkarunanithi:Fix-29544-Android

Conversation

@praveenkumarkarunanithi
Copy link
Copy Markdown
Contributor

@praveenkumarkarunanithi praveenkumarkarunanithi commented Apr 16, 2026

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 on Android, UpdateFromPosition runs before the carousel is fully initialized (_initialized = false). It sets _gotoPosition during an initial scroll attempt, but since the layout is not ready, the scroll never completes. This leaves _gotoPosition stuck at a non-negative value.

Earlier, this was unintentionally handled by an unconditional _gotoPosition = -1 in UpdateFromCurrentItem, which cleared the stale state. PR #34570 removed that line (to avoid breaking the guard during animations for #29544), exposing the issue.

As a result, _gotoPosition remains stuck, causing all subsequent UpdateFromPosition calls to fail the _gotoPosition == -1 check and skip scrolling. This leads to timeouts in tests like Issue23291 and Issue29216, as the carousel never moves to the requested position.

Description of Change

Updated the guard condition in UpdateFromPosition by applying the _initialized check only to the _gotoPosition assignment, ensuring it is set only after initialization while leaving the rest of the logic unaffected.
This prevents premature or stale _gotoPosition values during startup and preserves the existing scroll behavior, keeping the change safe.

Issues Fixed

Fixes regression introduced by #34570 :
Issue23291Test
Issue29216CarouselViewScrollingIssue on Candidate branch.

Tested the behaviour in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

@dotnet-policy-service dotnet-policy-service Bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Apr 16, 2026
@praveenkumarkarunanithi praveenkumarkarunanithi changed the title Update MauiCarouselRecyclerView.cs [Android] Fix Issue23291 and Issue29216 CarouselView test failures caused by _gotoPosition guard stuck during startup Apr 16, 2026
@praveenkumarkarunanithi praveenkumarkarunanithi added the area-controls-collectionview CollectionView, CarouselView, IndicatorView label Apr 16, 2026
@praveenkumarkarunanithi praveenkumarkarunanithi changed the title [Android] Fix Issue23291 and Issue29216 CarouselView test failures caused by _gotoPosition guard stuck during startup [Android] Fix CarouselView Issue23291 and Issue29216 test regression on candidate branch caused by #34570 Apr 16, 2026
@praveenkumarkarunanithi praveenkumarkarunanithi changed the title [Android] Fix CarouselView Issue23291 and Issue29216 test regression on candidate branch caused by #34570 [Android] Fix CarouselView Issue23291 and Issue29216 test regression on candidate branch Apr 16, 2026
@sheiksyedm sheiksyedm added the area-testing Unit tests, device tests label Apr 16, 2026
@sheiksyedm sheiksyedm marked this pull request as ready for review April 16, 2026 11:41
@sheiksyedm
Copy link
Copy Markdown
Contributor

/azp run maui-pr-uitests

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@sheiksyedm
Copy link
Copy Markdown
Contributor

/azp run maui-pr-uitests

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@kubaflo kubaflo merged commit 5057b14 into dotnet:inflight/candidate Apr 17, 2026
94 of 159 checks passed
@github-actions github-actions Bot added this to the .NET 10 SR6 milestone Apr 17, 2026
kubaflo pushed a commit that referenced this pull request Apr 21, 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
Ahamed-Ali pushed a commit that referenced this pull request Apr 22, 2026
…on candidate branch (#34996)

<!-- 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 on Android, `UpdateFromPosition` runs before
the carousel is fully initialized (`_initialized = false`). It sets
`_gotoPosition` during an initial scroll attempt, but since the layout
is not ready, the scroll never completes. This leaves `_gotoPosition`
stuck at a non-negative value.

Earlier, this was unintentionally handled by an unconditional
`_gotoPosition = -1` in `UpdateFromCurrentItem`, which cleared the stale
state. PR #34570 removed that line (to avoid breaking the guard during
animations for #29544), exposing the issue.

As a result, `_gotoPosition` remains stuck, causing all subsequent
`UpdateFromPosition` calls to fail the `_gotoPosition == -1` check and
skip scrolling. This leads to timeouts in tests like `Issue23291` and
`Issue29216`, as the carousel never moves to the requested position.
 
### Description of Change
Updated the guard condition in `UpdateFromPosition` by applying the
`_initialized` check only to the `_gotoPosition` assignment, ensuring it
is set only after initialization while leaving the rest of the logic
unaffected.
This prevents premature or stale `_gotoPosition` values during startup
and preserves the existing scroll behavior, keeping the change safe.

 
### Issues Fixed
Fixes regression introduced by #34570 : 
`Issue23291Test`
`Issue29216CarouselViewScrollingIssue  on Candidate branch`.
 
Tested the behaviour in the following platforms
- [x] Android
- [ ] Windows
- [ ] iOS
- [ ] Mac
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-controls-collectionview CollectionView, CarouselView, IndicatorView area-testing Unit tests, device tests partner/syncfusion Issues / PR's with Syncfusion collaboration regressed-in-inflight/candidate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants