[WIP][iOS] Horizontal CollectionView jumps to beginning - #37307
Draft
SubhikshaSf4851 wants to merge 3 commits into
Draft
[WIP][iOS] Horizontal CollectionView jumps to beginning#37307SubhikshaSf4851 wants to merge 3 commits into
SubhikshaSf4851 wants to merge 3 commits into
Conversation
SubhikshaSf4851
temporarily deployed
to
copilot-pat-pool
August 11, 2026 06:12 — with
GitHub Actions
Inactive
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 37307Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 37307" |
SubhikshaSf4851
temporarily deployed
to
copilot-pat-pool
August 11, 2026 06:12 — with
GitHub Actions
Inactive
|
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. |
SubhikshaSf4851
temporarily deployed
to
copilot-pat-pool
August 11, 2026 06:13 — with
GitHub Actions
Inactive
SubhikshaSf4851
temporarily deployed
to
copilot-pat-pool
August 11, 2026 06:14 — with
GitHub Actions
Inactive
SubhikshaSf4851
had a problem deploying
to
copilot-pat-pool
August 11, 2026 06:15 — with
GitHub Actions
Failure
SubhikshaSf4851
temporarily deployed
to
copilot-pat-pool
August 11, 2026 06:16 — with
GitHub Actions
Inactive
SubhikshaSf4851
force-pushed
the
Fix-36546
branch
from
August 11, 2026 10:08
b5290b3 to
8c05c3d
Compare
3 tasks
…earAfterRotatingTheDevice
Contributor
|
/azp run maui-pr-uitests , maui-pr-devicetests |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
Contributor
|
/azp run maui-pr-uitests , maui-pr-devicetests |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
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 whether this change resolves your issue. Thank you!
This pull request resolves a build-breaking duplicate-method conflict between two independent
CustomUICollectionViewCompositionalLayoutfixes on iOS, while preserving the rotation-invalidation behavior that #32664 introduced for #32435.Issue Details
PR #36546's fix added a
ShouldInvalidateLayoutForBoundsChange(CGRect newBounds)override (with_currentSizetracking viaPrepareLayout()) toCustomUICollectionViewCompositionalLayoutinLayoutFactory2.cs, to stop unrelated ancestor/sibling layout passes from resetting the CollectionView's scroll position.PR #32664 had already added a second override of the exact same method (
ShouldInvalidateLayoutForBoundsChange) in the same class, to fix #32435 — text disappearing in a horizontal CollectionView after rotating the simulator, because the compositional layout's defaultShouldInvalidateLayoutForBoundsChangereturnsfalseand never re-measures cells after a bounds change.Having two overrides of the same method in the same class does not compile (
CS0111: Type already defines a member with the same parameter types).Description of Change
Removed the duplicate override:
ShouldInvalidateLayoutForBoundsChange(CGRect newBounds)override fromCustomUICollectionViewCompositionalLayoutinLayoutFactory2.cs. The_currentSize/PrepareLayout()-based override from iOS Horizontal CollectionView jumps to beginning #36546 is kept, since it already covers the "ignore same-size bounds changes" case for both scenarios.Restored rotation invalidation via the view controller instead of the layout:
ItemsViewController2:_isRotatingand_orientationObserverfields.UIDevice.OrientationDidChangeNotificationinViewDidLoad(), setting_isRotating = truein theDeviceOrientationChangedhandler.Dispose(bool)to avoid leaks.ViewWillLayoutSubviews(), when_isRotatingis set, explicitly callCollectionView.CollectionViewLayout.InvalidateLayout()to force cells to re-measure/re-render after the rotation completes, then reset_isRotating.This keeps the #36546 scroll-jump fix intact (layout still returns
falsefor same-size bounds changes) while independently guaranteeing a genuine invalidation happens after a real device rotation, without needing two competing overrides of the same UIKit method.Why tests not added
The scroll-reset scenario from #36546 is intermittent and doesn't reproduce reliably at the same item/position, so it isn't suited to an automated test. The rotation fix for #32435 already has manual UI test coverage from #32664 (
Issue32435.csinTestCases.HostApp/TestCases.Shared.Tests), which continues to apply here.Issues Fixed
Fixes #36546
Tested the behavior in the following platforms
BeforeFix36546.mov
AfterFix36546.mov