Repository navigation
[iOS] Fix: Carouselview restores stale Position over CurrentItem after off-screen ItemsSource Change - #36681
Merged
Conversation
…r off-screen ItemsSource Change
SubhikshaSf4851
had a problem deploying
to
copilot-pat-pool
July 20, 2026 13:55 — with
GitHub Actions
Failure
|
Azure Pipelines: Successfully started running 1 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Hey there @@SubhikshaSf4851! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
sheiksyedm
marked this pull request as ready for review
July 20, 2026 14:29
|
Azure Pipelines: Successfully started running 1 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
3 tasks
Open
3 tasks
kubaflo
pushed a commit
that referenced
this pull request
Jul 22, 2026
…r off-screen ItemsSource Change (#36681) <!-- Please keep the note below for people who 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 whether this change resolves your issue. Thank you! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> This pull request addresses an issue with `CarouselView` on iOS where replacing the `ItemsSource` and setting a new `CurrentItem` while the view is detached could result in the wrong item being displayed when reattached. The update ensures that the new `CurrentItem` is respected over any stale `Position` value after the `ItemsSource` is replaced while detached. Additionally, a new test is added to prevent regressions for this scenario. This is a regression introduced by #36287, which added `_lastSyncedPosition` tracking and a reattach heuristic in `CarouselViewController2.cs`. That change unconditionally reset `_lastSyncedPosition` on every `ItemsSource` update — even while detached, when the `Position`/`CurrentItem` reset is skipped — causing the stale `Position` to be wrongly treated as an explicit user change on reattach and overriding a valid `CurrentItem` set on the replacement source. ### Description of change **Bug Fixes:** * Updated `CarouselViewController2.cs` to reset the tracked position correctly when the `ItemsSource` is replaced, ensuring the new `CurrentItem` is honored over a stale `Position` after reattaching the view. This addresses the regression introduced in #36287. **Testing:** * Added a new test `CarouselViewHonorsCurrentItemOverStalePositionAfterDetachedItemsSourceReplacement` in `CarouselViewTests.iOS.cs` to verify that replacing the `ItemsSource` and setting a new `CurrentItem` while detached works as expected after reattaching. * Introduced a helper method `SetupBuilderForDetachedItemsSourceReplacement` to configure handlers for the test scenario. <!-- Enter description of the fix in this section --> ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #36602 ### Tested the behavior in the following platforms - [ ] Windows - [ ] Android - [x] iOS - [ ] Mac | Before Issue Fix | After Issue Fix | |----------|----------| | <video src="https://github.com/user-attachments/assets/881dbe8f-323b-49ba-894d-f23fd368651c"> | <video src="https://github.com/user-attachments/assets/e55b5e56-4d74-4ad5-83b9-d63b41c6e503"> | <!-- <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
kubaflo
pushed a commit
that referenced
this pull request
Jul 28, 2026
…r off-screen ItemsSource Change (#36681) <!-- Please keep the note below for people who 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 whether this change resolves your issue. Thank you! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> This pull request addresses an issue with `CarouselView` on iOS where replacing the `ItemsSource` and setting a new `CurrentItem` while the view is detached could result in the wrong item being displayed when reattached. The update ensures that the new `CurrentItem` is respected over any stale `Position` value after the `ItemsSource` is replaced while detached. Additionally, a new test is added to prevent regressions for this scenario. This is a regression introduced by #36287, which added `_lastSyncedPosition` tracking and a reattach heuristic in `CarouselViewController2.cs`. That change unconditionally reset `_lastSyncedPosition` on every `ItemsSource` update — even while detached, when the `Position`/`CurrentItem` reset is skipped — causing the stale `Position` to be wrongly treated as an explicit user change on reattach and overriding a valid `CurrentItem` set on the replacement source. ### Description of change **Bug Fixes:** * Updated `CarouselViewController2.cs` to reset the tracked position correctly when the `ItemsSource` is replaced, ensuring the new `CurrentItem` is honored over a stale `Position` after reattaching the view. This addresses the regression introduced in #36287. **Testing:** * Added a new test `CarouselViewHonorsCurrentItemOverStalePositionAfterDetachedItemsSourceReplacement` in `CarouselViewTests.iOS.cs` to verify that replacing the `ItemsSource` and setting a new `CurrentItem` while detached works as expected after reattaching. * Introduced a helper method `SetupBuilderForDetachedItemsSourceReplacement` to configure handlers for the test scenario. <!-- Enter description of the fix in this section --> ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #36602 ### Tested the behavior in the following platforms - [ ] Windows - [ ] Android - [x] iOS - [ ] Mac | Before Issue Fix | After Issue Fix | |----------|----------| | <video src="https://github.com/user-attachments/assets/881dbe8f-323b-49ba-894d-f23fd368651c"> | <video src="https://github.com/user-attachments/assets/e55b5e56-4d74-4ad5-83b9-d63b41c6e503"> | <!-- <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
kubaflo
pushed a commit
that referenced
this pull request
Jul 29, 2026
…r off-screen ItemsSource Change (#36681) <!-- Please keep the note below for people who 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 whether this change resolves your issue. Thank you! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> This pull request addresses an issue with `CarouselView` on iOS where replacing the `ItemsSource` and setting a new `CurrentItem` while the view is detached could result in the wrong item being displayed when reattached. The update ensures that the new `CurrentItem` is respected over any stale `Position` value after the `ItemsSource` is replaced while detached. Additionally, a new test is added to prevent regressions for this scenario. This is a regression introduced by #36287, which added `_lastSyncedPosition` tracking and a reattach heuristic in `CarouselViewController2.cs`. That change unconditionally reset `_lastSyncedPosition` on every `ItemsSource` update — even while detached, when the `Position`/`CurrentItem` reset is skipped — causing the stale `Position` to be wrongly treated as an explicit user change on reattach and overriding a valid `CurrentItem` set on the replacement source. ### Description of change **Bug Fixes:** * Updated `CarouselViewController2.cs` to reset the tracked position correctly when the `ItemsSource` is replaced, ensuring the new `CurrentItem` is honored over a stale `Position` after reattaching the view. This addresses the regression introduced in #36287. **Testing:** * Added a new test `CarouselViewHonorsCurrentItemOverStalePositionAfterDetachedItemsSourceReplacement` in `CarouselViewTests.iOS.cs` to verify that replacing the `ItemsSource` and setting a new `CurrentItem` while detached works as expected after reattaching. * Introduced a helper method `SetupBuilderForDetachedItemsSourceReplacement` to configure handlers for the test scenario. <!-- Enter description of the fix in this section --> ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #36602 ### Tested the behavior in the following platforms - [ ] Windows - [ ] Android - [x] iOS - [ ] Mac | Before Issue Fix | After Issue Fix | |----------|----------| | <video src="https://github.com/user-attachments/assets/881dbe8f-323b-49ba-894d-f23fd368651c"> | <video src="https://github.com/user-attachments/assets/e55b5e56-4d74-4ad5-83b9-d63b41c6e503"> | <!-- <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
kubaflo
pushed a commit
that referenced
this pull request
Aug 7, 2026
…r off-screen ItemsSource Change (#36681) <!-- Please keep the note below for people who 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 whether this change resolves your issue. Thank you! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> This pull request addresses an issue with `CarouselView` on iOS where replacing the `ItemsSource` and setting a new `CurrentItem` while the view is detached could result in the wrong item being displayed when reattached. The update ensures that the new `CurrentItem` is respected over any stale `Position` value after the `ItemsSource` is replaced while detached. Additionally, a new test is added to prevent regressions for this scenario. This is a regression introduced by #36287, which added `_lastSyncedPosition` tracking and a reattach heuristic in `CarouselViewController2.cs`. That change unconditionally reset `_lastSyncedPosition` on every `ItemsSource` update — even while detached, when the `Position`/`CurrentItem` reset is skipped — causing the stale `Position` to be wrongly treated as an explicit user change on reattach and overriding a valid `CurrentItem` set on the replacement source. ### Description of change **Bug Fixes:** * Updated `CarouselViewController2.cs` to reset the tracked position correctly when the `ItemsSource` is replaced, ensuring the new `CurrentItem` is honored over a stale `Position` after reattaching the view. This addresses the regression introduced in #36287. **Testing:** * Added a new test `CarouselViewHonorsCurrentItemOverStalePositionAfterDetachedItemsSourceReplacement` in `CarouselViewTests.iOS.cs` to verify that replacing the `ItemsSource` and setting a new `CurrentItem` while detached works as expected after reattaching. * Introduced a helper method `SetupBuilderForDetachedItemsSourceReplacement` to configure handlers for the test scenario. <!-- Enter description of the fix in this section --> ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #36602 ### Tested the behavior in the following platforms - [ ] Windows - [ ] Android - [x] iOS - [ ] Mac | Before Issue Fix | After Issue Fix | |----------|----------| | <video src="https://github.com/user-attachments/assets/881dbe8f-323b-49ba-894d-f23fd368651c"> | <video src="https://github.com/user-attachments/assets/e55b5e56-4d74-4ad5-83b9-d63b41c6e503"> | <!-- <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
kubaflo
pushed a commit
that referenced
this pull request
Aug 12, 2026
…r off-screen ItemsSource Change (#36681) <!-- Please keep the note below for people who 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 whether this change resolves your issue. Thank you! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> This pull request addresses an issue with `CarouselView` on iOS where replacing the `ItemsSource` and setting a new `CurrentItem` while the view is detached could result in the wrong item being displayed when reattached. The update ensures that the new `CurrentItem` is respected over any stale `Position` value after the `ItemsSource` is replaced while detached. Additionally, a new test is added to prevent regressions for this scenario. This is a regression introduced by #36287, which added `_lastSyncedPosition` tracking and a reattach heuristic in `CarouselViewController2.cs`. That change unconditionally reset `_lastSyncedPosition` on every `ItemsSource` update — even while detached, when the `Position`/`CurrentItem` reset is skipped — causing the stale `Position` to be wrongly treated as an explicit user change on reattach and overriding a valid `CurrentItem` set on the replacement source. **Bug Fixes:** * Updated `CarouselViewController2.cs` to reset the tracked position correctly when the `ItemsSource` is replaced, ensuring the new `CurrentItem` is honored over a stale `Position` after reattaching the view. This addresses the regression introduced in #36287. **Testing:** * Added a new test `CarouselViewHonorsCurrentItemOverStalePositionAfterDetachedItemsSourceReplacement` in `CarouselViewTests.iOS.cs` to verify that replacing the `ItemsSource` and setting a new `CurrentItem` while detached works as expected after reattaching. * Introduced a helper method `SetupBuilderForDetachedItemsSourceReplacement` to configure handlers for the test scenario. <!-- Enter description of the fix in this section --> <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #36602 - [ ] Windows - [ ] Android - [x] iOS - [ ] Mac | Before Issue Fix | After Issue Fix | |----------|----------| | <video src="https://github.com/user-attachments/assets/881dbe8f-323b-49ba-894d-f23fd368651c"> | <video src="https://github.com/user-attachments/assets/e55b5e56-4d74-4ad5-83b9-d63b41c6e503"> | <!-- <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
This branch had an error being deployed
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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 whether this change resolves your issue. Thank you!
This pull request addresses an issue with
CarouselViewon iOS where replacing theItemsSourceand setting a newCurrentItemwhile the view is detached could result in the wrong item being displayed when reattached. The update ensures that the newCurrentItemis respected over any stalePositionvalue after theItemsSourceis replaced while detached. Additionally, a new test is added to prevent regressions for this scenario.This is a regression introduced by #36287, which added
_lastSyncedPositiontracking and a reattach heuristic inCarouselViewController2.cs. That change unconditionally reset_lastSyncedPositionon everyItemsSourceupdate — even while detached, when thePosition/CurrentItemreset is skipped — causing the stalePositionto be wrongly treated as an explicit user change on reattach and overriding a validCurrentItemset on the replacement source.Description of change
Bug Fixes:
CarouselViewController2.csto reset the tracked position correctly when theItemsSourceis replaced, ensuring the newCurrentItemis honored over a stalePositionafter reattaching the view. This addresses the regression introduced in [iOS/Mac] Fix CarouselView Position and IndicatorView Not Updating When Moving to Next Item in CV2 #36287.Testing:
CarouselViewHonorsCurrentItemOverStalePositionAfterDetachedItemsSourceReplacementinCarouselViewTests.iOS.csto verify that replacing theItemsSourceand setting a newCurrentItemwhile detached works as expected after reattaching.SetupBuilderForDetachedItemsSourceReplacementto configure handlers for the test scenario.Issues Fixed
Fixes #36602
Tested the behavior in the following platforms
BeforeFix36602-.mov
AfterFix36602-.mov