Repository navigation
[main] [iOS/MacCatalyst] Fix RTL CollectionView item positioning after rotation - #39894
Merged
Merged
Conversation
…ion (#39891) <!-- 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! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Description of Change RTL CollectionView items can become horizontally displaced after device rotation and scrolling. During preferred sizing, the managed item is arranged before UIKit applies the updated native bounds. RTL positioning can therefore use the previous parent width. Existing layout optimizations may skip a subsequent managed arrangement, leaving recycled items incorrectly positioned. This change: - Tracks the native content width used during managed arrangement. - Corrects the native item position when an RTL cell receives a different content width. - Reuses the existing native arrangement path without adding managed subtree arrange passes. - Adds LTR and RTL device tests covering initial sizing, widening/narrowing, reuse, and managed-arrange counts. The fix uses `TemplatedCell2.LayoutSubviews`. It does not modify `ItemsViewController2` or restore the removed `ViewDidLayoutSubviews` override. Validation on iOS: - Reproduced the issue in Sandbox using the post-revert SR13 source. - Confirmed the RTL regression test fails without the fix: native X is −200 instead of 0. - Confirmed both RTL and LTR cases pass with the fix. - Confirmed the Sandbox rotation-and-scroll scenario remains aligned. ### Regression reason This regression issue was originally introduced by PR #37437. A fix was later added through PR #38771 and merged into the candidate branch. However, the fix was subsequently reverted by PR #39707 due to test failures encountered during validation. ### 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 #38622 <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
This comment has been minimized.
This comment has been minimized.
kubaflo
approved these changes
Nov 4, 2026
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.
Backport of #39891 to main
/cc @sheiksyedm