Skip to content

[iOS/MacCatalyst] Fix RTL CollectionView item positioning after rotation - #39891

Merged
kubaflo merged 1 commit into
dotnet:release/10.0.1xx-sr13from
sheiksyedm:sheiksyedm-sr13-rtl-fix-only
Nov 4, 2026
Merged

kubaflo merged 1 commit into
dotnet:release/10.0.1xx-sr13from
sheiksyedm:sheiksyedm-sr13-rtl-fix-only

Conversation

@sheiksyedm

@sheiksyedm sheiksyedm commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

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!

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

Fixes #38622

Realign the native item root when preferred sizing used an outdated parent width, without adding managed subtree arrange passes. Add RTL and LTR device tests for resizing, reuse, and arrange counts.

Fixes dotnet#38622
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 39891

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 39891"

@dotnet-policy-service dotnet-policy-service Bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Nov 4, 2026
@azure-pipelines

This comment has been minimized.

@sheiksyedm
sheiksyedm requested a balanced review from Copilot November 4, 2026 12:41
@kubaflo

This comment has been minimized.

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Nov 4, 2026
@azure-pipelines

This comment has been minimized.

@github-actions github-actions Bot added area-controls-collectionview CollectionView, CarouselView, IndicatorView platform/ios platform/macos macOS / Mac Catalyst labels Nov 4, 2026
@sheiksyedm sheiksyedm added the community ✨ Community Contribution label Nov 4, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The fix depends on UIKit layout timing, requiring platform validation of rotation, reuse, and MacCatalyst resizing beyond the test’s manual bounds and layout calls.

No open issues 🎉

What changed in this PR

Addresses #38622 by correcting RTL CollectionView item positioning after rotation in the iOS/MacCatalyst Items2 handler, without adding managed subtree arrange passes.

Changes:

  • Tracks the native content width used during managed arrangement.
  • Repositions RTL content when native width changes and managed arrangement is skipped.
  • Adds LTR and RTL device tests covering resizing, cell reuse, alignment, and arrange counts.
File Description
src/​Controls/​tests/​DeviceTests/​Elements/​CollectionView/​TemplatedCellTests.iOS.cs Adds alignment and arrange-count regression tests for LTR and RTL cells.
src/​Controls/​src/​Core/​Handlers/​Items2/​iOS/​TemplatedCell2.cs Tracks content width and corrects stale RTL positioning during native layout.

Review effort: Balanced

@MauiBot

MauiBot commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

PR Test Gate

@sheiksyedm — existing-test verification for commit 89005a26.

Result SKIPPED Platform Android Commit 89005a26


🧪 Gate analysis — click to expand

⚠ Skipped. No runnable PR tests were selected. The fix has not been verified by this gate.

No interpretable test-group summary was produced. No additional test execution is inferred.

PR head: 89005a26.

Without-fix baseline: 07aca508.

@MauiBot MauiBot removed the s/agent-review-in-progress AI review is currently running for this PR label Nov 4, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expert Review — 0 findings

Reviewed commit 89005a2.

@sheiksyedm
sheiksyedm marked this pull request as ready for review November 4, 2026 13:56
@sheiksyedm
sheiksyedm requested a review from kubaflo November 4, 2026 14:23
@kubaflo
kubaflo merged commit 54d7645 into dotnet:release/10.0.1xx-sr13 Nov 4, 2026
42 of 59 checks passed
@github-actions github-actions Bot added this to the .NET 10 SR13 milestone Nov 4, 2026
@sheiksyedm

Copy link
Copy Markdown
Contributor Author

/backport to main

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Started backporting to main (link to workflow run)

kubaflo added a commit that referenced this pull request Nov 4, 2026
…r rotation (#39894)

Backport of #39891 to main

/cc @sheiksyedm

Co-authored-by: Sheik Syed <sheiksyedm@syncfusion.com>
Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 13, 2026
…on backports (#40217)

<!-- 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

**Explicit release-target exception:** this PR intentionally targets the
new `release/10.0.1xx-sr14` branch. `main`, `net11` and the inflight
lanes are now .NET 11, so .NET 10 SR14 is cut from the SR13 release head
(`release/10.0.1xx-sr14` was created at `54d76458e0`, the tip of
`release/10.0.1xx-sr13`, which already includes all post-cut SR13 fixes
#39830, #39855, #39879, #39891 and the servicing/stable configuration
from #39774).

This PR brings the .NET 10 changes needed since SR13:

1. **Backport #39887** – `[Windows] Prevent duplicate Shell startup
navigation from stale tab selection events`. Fixes #39859 (regressed in
10.0.120); it was merged only to `main`. Clean `cherry-pick -x`.
2. **Backport #40132** – `Fix custom Shape.PathForBounds dispatch
regression`. Fixes #40129 (regressed in 10.0.130); it was merged only to
`candidate/11.0.1xx-sr2`. The unrelated .NET 11
`eng/release-rollover.json` change from that commit is excluded (file
does not exist on the .NET 10 line).
3. **Version bump** – `PatchVersion` 130 → 140 in `eng/Versions.props`.
Servicing label and `StabilizePackageVersion=true` are inherited from
SR13.

Reviewed and intentionally **not** included:

- #40136 (`net10.0` Publish-Build-Assets cleanup): SR13 has no
`Publish-Build-Assets` references, so nothing to remove.
- #39882 (re-land of the CollectionView2 height fix): SR13 already
carries the revert #39855 that fixed #39847; re-landing is a
fix-forward, not a regression fix.
- #40213 (`[net10.0][XSG]` CA2252 suppression, issue #40045): still
open/unmerged; can be backported once approved.
- Other `regressed-in-10.0.1x0` issues closed since the SR13 cut
(#38622, #39557/#39681, #39722) are already fixed on SR13 or were fixed
outside MAUI.

Keep in draft pending review and CI. This PR does not tag, publish, or
authorize a release; the internal dnceng mirror of
`release/10.0.1xx-sr14` has not been created.

#### Validation

Using the pinned SDK `10.0.113` provisioned by `eng/common/dotnet.sh`:

- `dotnet msbuild eng/Versions.props
-getProperty:PatchVersion,SdkBandVersion,PreReleaseVersionLabel,StabilizePackageVersion,DotNetFinalVersionKind`
→ `140`, `10.0.100`, `servicing`, `true`, `release`. `xmllint --noout
eng/Versions.props` passed.
- `dotnet test
src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj -f
net10.0 --filter FullyQualifiedName~StrokeShapeTests` (platform TFMs
disabled): **passed 59/59**. With `Shape.cs` reverted to SR13: **failed
3/59** (the new `CustomShapeReimplementingIShape*` tests); restored:
**passed 59/59**.
- #39887 is Windows-only (`ShellItemHandler.Windows.cs` + Windows device
test) and was not built locally on macOS; it relies on CI.

### Issues Fixed

Fixes #39859
Fixes #40129

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->

---------

This branch was previously deployed

1 inactive deployment
copilot-pat-pool — 89005a26 Deployed Nov 4, 2026 by sheiksyedm via conclusion #2693
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 community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/ios platform/macos macOS / Mac Catalyst

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[MAUI] I1_RTL_FlowDirection - Rotating the iOS simulator causes the item layout to change

4 participants