Skip to content

[iOS/MacCatalyst] Fix CollectionView ScrollTo for horizontal layouts#33853

Merged
PureWeen merged 1 commit intodotnet:inflight/currentfrom
Shalini-Ashokan:fix-33852
Feb 23, 2026
Merged

[iOS/MacCatalyst] Fix CollectionView ScrollTo for horizontal layouts#33853
PureWeen merged 1 commit intodotnet:inflight/currentfrom
Shalini-Ashokan:fix-33852

Conversation

@Shalini-Ashokan
Copy link
Copy Markdown
Contributor

@Shalini-Ashokan Shalini-Ashokan commented Feb 3, 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!

Issue Details

CollectionView’s programmatic ScrollTo does not work when using a horizontal ItemsLayout on iOS/MacCatalyst. After calling ScrollTo(index, position: ScrollToPosition.Start, animate: true), the scroll position remains unchanged.

Root Cause

In the CV2 iOS handler, the scroll direction is hardcoded to Vertical instead of using the actual layout direction. As a result, horizontal layouts receive incorrect scroll position calculations.

Description of Change

Replace the hardcoded vertical direction with a dynamic call that retrieves the actual scroll direction from the controller. This ensures that horizontal layouts receive the correct scroll position values.

Fix reference

I have fixed the issue in the same way as CV1, by referring to the following code.

Controller.CollectionView.ScrollToItem(indexPath,

Validated the behavior in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

Issues Fixed

Fixes #33852

Output ScreenShot

Before After
Before-Fix.mov
After-Fix.mov

@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Hey there @@Shalini-Ashokan! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@dotnet-policy-service dotnet-policy-service bot added community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration labels Feb 3, 2026
@sheiksyedm sheiksyedm added area-controls-collectionview CollectionView, CarouselView, IndicatorView collectionview-cv2 platform/ios labels Feb 3, 2026
@sheiksyedm sheiksyedm marked this pull request as ready for review February 3, 2026 09:49
@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).

@rmarinho
Copy link
Copy Markdown
Member

rmarinho commented Feb 18, 2026

🤖 AI Summary

📊 Expand Full Review
🔍 Pre-Flight — Context & Validation
📝 Review SessionFixed the collection view scroll to issue · 345ea8d

Issue: #33852 - [iOS/MacCatalyst] CollectionView ScrollTo does not work with horizontal Layout
Platforms Affected: iOS, MacCatalyst
Files Changed: 1 implementation file, 2 test files

Issue Summary

CollectionView's programmatic ScrollTo does not work when using a horizontal ItemsLayout on iOS/MacCatalyst. After calling ScrollTo(index, position: ScrollToPosition.Start, animate: true), the scroll position remains unchanged. This issue affects only the CV2 (CollectionView2) handler; CV1 works correctly.

Root Cause (from PR description)

In ItemsViewHandler2.iOS.cs, the scroll direction was hardcoded to UICollectionViewScrollDirection.Vertical. Horizontal layouts received incorrect scroll position calculations.

Files Changed

  • Fix file: src/Controls/src/Core/Handlers/Items2/ItemsViewHandler2.iOS.cs (+2, -1)
    • Line ~149: Replace hardcoded UICollectionViewScrollDirection.Vertical with Controller.GetScrollDirection()
  • Test file: src/Controls/tests/TestCases.HostApp/Issues/Issue33852.cs (+85, new)
    • Uses CollectionView2 with horizontal layout, button to ScrollTo item 15, label showing scroll state
  • Test file: src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue33852.cs (+24, new)
    • UI test ProgrammaticScrollToWorksWithHorizontalLayout - taps ScrollToButton, verifies IndexLabel text

PR Discussion Summary

  • No reviewer disagreements or inline review comments
  • CI pipeline (maui-pr-uitests) was triggered by team member sheiksyedm
  • Author validated fix on Android, Windows, iOS, Mac

Fix Candidates

# Source Approach Test Result Files Changed Notes
PR PR #33853 Replace hardcoded UICollectionViewScrollDirection.Vertical with Controller.GetScrollDirection() in ScrollToRequested ⏳ PENDING (Gate) ItemsViewHandler2.iOS.cs (+2/-1) Original PR - matches CV1 fix pattern

🚦 Gate — Test Verification
📝 Review SessionFixed the collection view scroll to issue · 345ea8d

Result: ✅ PASSED
Platform: ios
Mode: Full Verification

  • Tests FAIL without fix ✅
  • Tests PASS with fix ✅

Test Filter: Issue33852
Fix File Validated: src/Controls/src/Core/Handlers/Items2/ItemsViewHandler2.iOS.cs


🔧 Fix — Analysis & Comparison
📝 Review SessionFixed the collection view scroll to issue · 345ea8d

Fix Candidates

# Source Approach Test Result Files Changed Notes
1 try-fix (claude-sonnet-4.5) Query ItemsLayout.Orientation from VirtualView cast to StructuredItemsView, convert to UICollectionViewScrollDirection ✅ PASS 1 file (+12/-1) More verbose, extra cast + null check
2 try-fix (claude-opus-4.6) Read UICollectionViewCompositionalLayout.Configuration.ScrollDirection directly from native layout ✅ PASS 1 file (+5/-1) Clean, direct, but tied to CompositionalLayout type
3 try-fix (gpt-5.2) Infer direction heuristically from ContentSize vs Bounds dimensions ✅ PASS 1 file (+20/-1) Fragile: depends on content being realized; could fail on empty/first-render
4 try-fix (gpt-5.2-codex) Compute target offset directly from item frame using SetContentOffset, bypassing ScrollToItem entirely ✅ PASS 1 file (+42/-3) Much more complex, 45 lines; changes scrolling mechanism fundamentally
5 try-fix (gemini) Use Controller.GetScrollDirection() - same as PR's fix ✅ PASS 1 file (+1/-1) Identical to PR fix
6 try-fix (claude-sonnet-4.5 R2) Check both UICollectionViewFlowLayout.ScrollDirection and UICollectionViewCompositionalLayout.Configuration.ScrollDirection ✅ PASS 1 file (+11/-1) More complex version of Attempt 2
7 try-fix (gpt-5.2 R2) ScrollRectToVisible with complex viewport-rect calculation using AdjustedContentInset ✅ PASS 1 file (+80/-2) Very complex, 80+ lines; changes scrolling mechanism entirely
8 try-fix (gemini R2) ScrollRectToVisible with simple GetLayoutAttributesForItem.Frame ✅ PASS 1 file (+6/-2) Simple but ignores ScrollToPosition alignment (Start/Center/End)
PR PR #33853 Replace hardcoded UICollectionViewScrollDirection.Vertical with Controller.GetScrollDirection() ✅ PASS (Gate) 1 file (+2/-1) Original PR - cleanest, uses existing infrastructure

Exhausted: Yes (rate limit hit after attempt 9; 8 of 8 attempts passed; all key approaches covered)
Selected Fix: PR's fix — Controller.GetScrollDirection() is the simplest, most direct, and reuses existing infrastructure that already correctly tracks the scroll direction. Only 2 lines changed.

Cross-Pollination Summary

Model Round 2 Round 3
claude-sonnet-4.5 NEW IDEA (FlowLayout check - ran as #6) NEW IDEA (caching - not run, rate limited)
claude-opus-4.6 NO NEW IDEAS
gpt-5.2 NEW IDEA (ScrollRectToVisible - ran as #7) NEW IDEA (force layout - not run, rate limited)
gpt-5.2-codex NO NEW IDEAS
gemini-3-pro-preview NEW IDEA (ScrollRectToVisible - ran as #8) NO NEW IDEAS

📋 Report — Final Recommendation
📝 Review SessionFixed the collection view scroll to issue · 345ea8d

✅ Final Recommendation: APPROVE

Summary

PR #33853 fixes a one-line bug in the CV2 (CollectionView2) iOS/MacCatalyst handler where ScrollToRequested hardcoded UICollectionViewScrollDirection.Vertical, causing ScrollTo to silently do nothing for horizontal layouts. The fix replaces the hardcoded value with Controller.GetScrollDirection(), matching how CV1 already handled this.


Root Cause

In ItemsViewHandler2.iOS.cs, ScrollToRequested always passed UICollectionViewScrollDirection.Vertical to ScrollToPositionExtensions.ToCollectionViewScrollPosition(). For a horizontal layout, this mapped ScrollToPosition.Start to UICollectionViewScrollPosition.Top instead of UICollectionViewScrollPosition.Left, causing ScrollToItem to silently no-op (cannot scroll vertically when the view is horizontal).


Fix Quality

The fix is correct, minimal, and well-aligned with existing patterns.

  • Only 2 lines changed in source (1 line added for scrollDirection, 1 line updated)
  • Controller.GetScrollDirection() is already used elsewhere in the same method for content size checks (lines ~197-206)
  • ItemsViewController2.GetScrollDirection() returns a cached ScrollDirection property updated during layout configuration
  • Identical pattern to CV1 at src/Controls/src/Core/Handlers/Items/ItemsViewHandler.iOS.cs:111 which uses _layout.ScrollDirection
  • 8 independent try-fix attempts confirmed this is the cleanest approach

PR Title & Description Review

Title: [iOS/MacCatalyst] Fix CollectionView ScrollTo for horizontal layouts

  • ✅ Platform prefix correct
  • ✅ Describes the fix clearly
  • Minor note: could say "CV2" to distinguish from CV1, but current title is clear enough

Description: Good structure with NOTE block, root cause, and fix description. Accurate.


Code Review Findings

🟡 Minor Issues (non-blocking)

1. Missing newline at end of file (both test files)

  • src/Controls/tests/TestCases.HostApp/Issues/Issue33852.cs (line 85)
  • src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue33852.cs (line 24)
  • Both end with } with no trailing newline. Standard convention is to add one.

2. Unnecessary string interpolation

  • src/Controls/tests/TestCases.HostApp/Issues/Issue33852.cs line ~72:
    _indexLabel.Text = $"The CollectionView is scrolled";  // $ is unnecessary, no interpolation
    Should be: _indexLabel.Text = "The CollectionView is scrolled";

3. Extra whitespace in StackLayout

  • src/Controls/tests/TestCases.HostApp/Issues/Issue33852.cs line ~63:
    Children =
    {
        _indexLabel,
         scrollToButton,  // extra leading space
        _collectionView

✅ Looks Good

  • Fix file change is clean, minimal, and correct
  • GetScrollDirection() is correctly placed before ToCollectionViewScrollPosition - no timing issues since layout direction is set during SetLayout
  • Test uses CollectionView2 (not CollectionView) - correctly targets the CV2 handler
  • [Category(UITestCategories.CollectionView)] appropriate category
  • Test correctly verifies functional behavior (label update via Scrolled event) rather than screenshots
  • PlatformAffected.iOS | PlatformAffected.macOS correctly set in [Issue] attribute

Fix Exploration Summary

8 alternative approaches were tested (all passed), confirming the bug is well-understood and the fix space is simple:

Approach Complexity Verdict
PR: Controller.GetScrollDirection() Minimal ✅ Best - 2 lines, reuses existing infrastructure
Query VirtualView.ItemsLayout.Orientation Medium ✅ Works but bypasses controller
Read CompositionalLayout.Configuration.ScrollDirection Medium ✅ Works, tied to native type
ContentSize vs Bounds heuristic High ⚠️ Fragile on empty/pre-render state
Direct SetContentOffset from frame Very high ✅ Works but 45 lines, fundamental change
ScrollRectToVisible simple Low ⚠️ Ignores Start/Center/End alignment
ScrollRectToVisible complex Very high ✅ Works but 80+ lines
FlowLayout + CompositionalLayout check Medium ✅ Works but overly defensive

Selected Fix: PR's fix is the clear winner - minimal change, consistent with CV1, uses existing infrastructure.


📋 Expand PR Finalization Review
Title: ✅ Good

Current: [iOS/MacCatalyst] Fix CollectionView ScrollTo for horizontal layouts

Description: ✅ Good

Description needs updates. See details below.

✨ Suggested PR Description

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

Issue Details

CollectionView's programmatic ScrollTo does not work when using a horizontal ItemsLayout on iOS/MacCatalyst. After calling ScrollTo(index, position: ScrollToPosition.Start, animate: true), the scroll position remains unchanged.

Root Cause

In the CV2 iOS handler (ItemsViewHandler2.iOS.cs), the scroll direction was hardcoded to UICollectionViewScrollDirection.Vertical when calculating the UICollectionViewScrollPosition. This caused incorrect scroll position values to be computed for horizontal layouts.

Description of Change

In ScrollToRequested, replaced the hardcoded UICollectionViewScrollDirection.Vertical with a call to Controller.GetScrollDirection(), which dynamically retrieves the actual scroll direction from the controller. This matches the approach already used in the CV1 handler (ItemsViewHandler.iOS.cs).

Changed file: src/Controls/src/Core/Handlers/Items2/ItemsViewHandler2.iOS.cs

Fix reference (CV1 pattern followed):

Controller.CollectionView.ScrollToItem(indexPath,

Platforms

Platform Status Notes
iOS ✅ Fixed Bug was here — horizontal scroll now works
Mac (MacCatalyst) ✅ Fixed Bug was here — horizontal scroll now works
Android ✅ No regression Unaffected (uses different handler)
Windows ✅ No regression Unaffected (uses different handler)

Issues Fixed

Fixes #33852

Code Review: ✅ Passed

Code Review: PR #33853

Code Review Findings


✅ Fix in ItemsViewHandler2.iOS.cs — Correct

Change:

// Before
var position = Items.ScrollToPositionExtensions.ToCollectionViewScrollPosition(
    args.ScrollToPosition, UICollectionViewScrollDirection.Vertical);

// After
var scrollDirection = Controller.GetScrollDirection();
var position = Items.ScrollToPositionExtensions.ToCollectionViewScrollPosition(
    args.ScrollToPosition, scrollDirection);

This is a minimal, correct fix. Controller.GetScrollDirection() returns ScrollDirection from ItemsViewController2, which reads from the layout. The same pattern (Controller.GetScrollDirection()) is already used in the same file at line 197 for EnsureContentSizeForScrollDirection, so this is consistent with existing code.

The CV1 handler (ItemsViewHandler.iOS.cs) uses _layout.ScrollDirection directly, which achieves the same result — reading the actual layout direction rather than assuming vertical.


🟡 Potential Test Flakiness — TestCases.Shared.Tests/Tests/Issues/Issue33852.cs

Issue: After tapping the ScrollTo button, the test immediately reads the label text with FindElement — no waiting for the label to update.

App.WaitForElement("ScrollToButton");
App.Tap("ScrollToButton");
var firstIndexText = App.FindElement("IndexLabel").GetText();  // ⚠️ No wait
Assert.That(firstIndexText, Is.EqualTo("The CollectionView is scrolled"));

ScrollTo is called with animate: true, making it asynchronous. The Scrolled event that updates the label fires as the collection view scrolls — but there's a race between the animation starting and the test reading the label. On a slow device or under load, the label may still show "ItemIndex: 0" (initial value from _indexLabel = new Label { Text = "ItemIndex: 0" }) when the assertion runs.

Recommendation: Wait for the expected label value before asserting:

App.WaitForElement("ScrollToButton");
App.Tap("ScrollToButton");
App.WaitForElement("IndexLabel");
// Optionally: wait for text to change, or use WaitFor with expected value
var firstIndexText = App.FindElement("IndexLabel").GetText();
Assert.That(firstIndexText, Is.EqualTo("The CollectionView is scrolled"));

A more robust fix would use a polling approach or animate: false for deterministic testing, since the goal is to verify the scroll happened, not that it animated smoothly.


🟡 Whitespace Inconsistency — TestCases.HostApp/Issues/Issue33852.cs

File: src/Controls/tests/TestCases.HostApp/Issues/Issue33852.cs, line 63

Children =
{
    _indexLabel,
     scrollToButton,   // ⚠️ extra leading space
    _collectionView
}

There is an extra space before scrollToButton that doesn't match the indentation of the surrounding items. Minor cosmetic issue.


🟡 Missing Trailing Newline — Both New Test Files

Both new test files (Issue33852.cs in HostApp and in Shared.Tests) are missing a trailing newline at end of file. The git diff shows \ No newline at end of file for both. Minor but worth fixing for consistency.


✅ Test Structure — Good

  • [Issue] attribute present with correct tracker, number, description, and PlatformAffected.iOS | PlatformAffected.macOS
  • AutomationId values set on all interactive elements (ScrollToButton, IndexLabel, TestCollectionView)
  • Uses CollectionView2 (which maps to CV2 handler via CollectionViewHostBuilderExtentions.cs)
  • Test inherits from _IssuesUITest
  • [Category(UITestCategories.CollectionView)] applied
  • Test method name ProgrammaticScrollToWorksWithHorizontalLayout is descriptive

Summary

Severity Finding
Core fix is correct and consistent with CV1 and existing CV2 code patterns
🟡 UI test may be flaky due to no wait after animated ScrollTo
🟡 Extra whitespace on line 63 of HostApp test
🟡 Missing trailing newline in both new test files

@rmarinho rmarinho added s/agent-approved AI agent recommends approval - PR fix is correct and optimal s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix) s/agent-fix-lose Author adopted the agent's fix and it turned out to be bad s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review) labels Feb 18, 2026
@kubaflo kubaflo added s/agent-fix-pr-picked AI could not beat the PR fix - PR is the best among all candidates and removed s/agent-fix-lose Author adopted the agent's fix and it turned out to be bad labels Feb 20, 2026
@PureWeen PureWeen changed the base branch from main to inflight/current February 23, 2026 22:26
@PureWeen PureWeen merged commit c189d4c into dotnet:inflight/current Feb 23, 2026
139 of 149 checks passed
github-actions bot pushed a commit that referenced this pull request Feb 24, 2026
…33853)

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

### Issue Details
CollectionView’s programmatic ScrollTo does not work when using a
horizontal ItemsLayout on iOS/MacCatalyst. After calling ScrollTo(index,
position: ScrollToPosition.Start, animate: true), the scroll position
remains unchanged.

### Root Cause
In the CV2 iOS handler, the scroll direction is hardcoded to Vertical
instead of using the actual layout direction. As a result, horizontal
layouts receive incorrect scroll position calculations.

### Description of Change
Replace the hardcoded vertical direction with a dynamic call that
retrieves the actual scroll direction from the controller. This ensures
that horizontal layouts receive the correct scroll position values.

### Fix reference

I have fixed the issue in the same way as CV1, by referring to the
following code.


https://github.com/dotnet/maui/blob/52f9fc2a308b518890cf6def72abe422ac997d85/src/Controls/src/Core/Handlers/Items/ItemsViewHandler.iOS.cs#L110

Validated the behavior in the following platforms
 
- [x] Android
- [x] Windows
- [x] iOS
- [x] Mac
 
### Issues Fixed
  
Fixes #33852 

### Output  ScreenShot

|Before|After|
|--|--|
| <video
src="https://github.com/user-attachments/assets/1d510715-83bf-412c-a8a3-6f8362dd52bd"
>| <video
src="https://github.com/user-attachments/assets/0283113a-33ed-4d14-9d1d-a18ab9f2e2d0">|
jfversluis pushed a commit that referenced this pull request Mar 2, 2026
…33853)

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

### Issue Details
CollectionView’s programmatic ScrollTo does not work when using a
horizontal ItemsLayout on iOS/MacCatalyst. After calling ScrollTo(index,
position: ScrollToPosition.Start, animate: true), the scroll position
remains unchanged.

### Root Cause
In the CV2 iOS handler, the scroll direction is hardcoded to Vertical
instead of using the actual layout direction. As a result, horizontal
layouts receive incorrect scroll position calculations.

### Description of Change
Replace the hardcoded vertical direction with a dynamic call that
retrieves the actual scroll direction from the controller. This ensures
that horizontal layouts receive the correct scroll position values.

### Fix reference

I have fixed the issue in the same way as CV1, by referring to the
following code.


https://github.com/dotnet/maui/blob/52f9fc2a308b518890cf6def72abe422ac997d85/src/Controls/src/Core/Handlers/Items/ItemsViewHandler.iOS.cs#L110

Validated the behavior in the following platforms
 
- [x] Android
- [x] Windows
- [x] iOS
- [x] Mac
 
### Issues Fixed
  
Fixes #33852 

### Output  ScreenShot

|Before|After|
|--|--|
| <video
src="https://github.com/user-attachments/assets/1d510715-83bf-412c-a8a3-6f8362dd52bd"
>| <video
src="https://github.com/user-attachments/assets/0283113a-33ed-4d14-9d1d-a18ab9f2e2d0">|
jfversluis pushed a commit that referenced this pull request Mar 2, 2026
…33853)

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

### Issue Details
CollectionView’s programmatic ScrollTo does not work when using a
horizontal ItemsLayout on iOS/MacCatalyst. After calling ScrollTo(index,
position: ScrollToPosition.Start, animate: true), the scroll position
remains unchanged.

### Root Cause
In the CV2 iOS handler, the scroll direction is hardcoded to Vertical
instead of using the actual layout direction. As a result, horizontal
layouts receive incorrect scroll position calculations.

### Description of Change
Replace the hardcoded vertical direction with a dynamic call that
retrieves the actual scroll direction from the controller. This ensures
that horizontal layouts receive the correct scroll position values.

### Fix reference

I have fixed the issue in the same way as CV1, by referring to the
following code.


https://github.com/dotnet/maui/blob/52f9fc2a308b518890cf6def72abe422ac997d85/src/Controls/src/Core/Handlers/Items/ItemsViewHandler.iOS.cs#L110

Validated the behavior in the following platforms
 
- [x] Android
- [x] Windows
- [x] iOS
- [x] Mac
 
### Issues Fixed
  
Fixes #33852 

### Output  ScreenShot

|Before|After|
|--|--|
| <video
src="https://github.com/user-attachments/assets/1d510715-83bf-412c-a8a3-6f8362dd52bd"
>| <video
src="https://github.com/user-attachments/assets/0283113a-33ed-4d14-9d1d-a18ab9f2e2d0">|
github-actions bot pushed a commit that referenced this pull request Mar 3, 2026
…33853)

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

### Issue Details
CollectionView’s programmatic ScrollTo does not work when using a
horizontal ItemsLayout on iOS/MacCatalyst. After calling ScrollTo(index,
position: ScrollToPosition.Start, animate: true), the scroll position
remains unchanged.

### Root Cause
In the CV2 iOS handler, the scroll direction is hardcoded to Vertical
instead of using the actual layout direction. As a result, horizontal
layouts receive incorrect scroll position calculations.

### Description of Change
Replace the hardcoded vertical direction with a dynamic call that
retrieves the actual scroll direction from the controller. This ensures
that horizontal layouts receive the correct scroll position values.

### Fix reference

I have fixed the issue in the same way as CV1, by referring to the
following code.


https://github.com/dotnet/maui/blob/52f9fc2a308b518890cf6def72abe422ac997d85/src/Controls/src/Core/Handlers/Items/ItemsViewHandler.iOS.cs#L110

Validated the behavior in the following platforms
 
- [x] Android
- [x] Windows
- [x] iOS
- [x] Mac
 
### Issues Fixed
  
Fixes #33852 

### Output  ScreenShot

|Before|After|
|--|--|
| <video
src="https://github.com/user-attachments/assets/1d510715-83bf-412c-a8a3-6f8362dd52bd"
>| <video
src="https://github.com/user-attachments/assets/0283113a-33ed-4d14-9d1d-a18ab9f2e2d0">|
HarishKumarSF4517 pushed a commit to HarishKumarSF4517/maui that referenced this pull request Mar 5, 2026
…otnet#33853)

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

### Issue Details
CollectionView’s programmatic ScrollTo does not work when using a
horizontal ItemsLayout on iOS/MacCatalyst. After calling ScrollTo(index,
position: ScrollToPosition.Start, animate: true), the scroll position
remains unchanged.

### Root Cause
In the CV2 iOS handler, the scroll direction is hardcoded to Vertical
instead of using the actual layout direction. As a result, horizontal
layouts receive incorrect scroll position calculations.

### Description of Change
Replace the hardcoded vertical direction with a dynamic call that
retrieves the actual scroll direction from the controller. This ensures
that horizontal layouts receive the correct scroll position values.

### Fix reference

I have fixed the issue in the same way as CV1, by referring to the
following code.


https://github.com/dotnet/maui/blob/52f9fc2a308b518890cf6def72abe422ac997d85/src/Controls/src/Core/Handlers/Items/ItemsViewHandler.iOS.cs#L110

Validated the behavior in the following platforms
 
- [x] Android
- [x] Windows
- [x] iOS
- [x] Mac
 
### Issues Fixed
  
Fixes dotnet#33852 

### Output  ScreenShot

|Before|After|
|--|--|
| <video
src="https://github.com/user-attachments/assets/1d510715-83bf-412c-a8a3-6f8362dd52bd"
>| <video
src="https://github.com/user-attachments/assets/0283113a-33ed-4d14-9d1d-a18ab9f2e2d0">|
github-actions bot pushed a commit that referenced this pull request Mar 6, 2026
…33853)

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

### Issue Details
CollectionView’s programmatic ScrollTo does not work when using a
horizontal ItemsLayout on iOS/MacCatalyst. After calling ScrollTo(index,
position: ScrollToPosition.Start, animate: true), the scroll position
remains unchanged.

### Root Cause
In the CV2 iOS handler, the scroll direction is hardcoded to Vertical
instead of using the actual layout direction. As a result, horizontal
layouts receive incorrect scroll position calculations.

### Description of Change
Replace the hardcoded vertical direction with a dynamic call that
retrieves the actual scroll direction from the controller. This ensures
that horizontal layouts receive the correct scroll position values.

### Fix reference

I have fixed the issue in the same way as CV1, by referring to the
following code.


https://github.com/dotnet/maui/blob/52f9fc2a308b518890cf6def72abe422ac997d85/src/Controls/src/Core/Handlers/Items/ItemsViewHandler.iOS.cs#L110

Validated the behavior in the following platforms
 
- [x] Android
- [x] Windows
- [x] iOS
- [x] Mac
 
### Issues Fixed
  
Fixes #33852 

### Output  ScreenShot

|Before|After|
|--|--|
| <video
src="https://github.com/user-attachments/assets/1d510715-83bf-412c-a8a3-6f8362dd52bd"
>| <video
src="https://github.com/user-attachments/assets/0283113a-33ed-4d14-9d1d-a18ab9f2e2d0">|
PureWeen added a commit that referenced this pull request Mar 11, 2026
## What's Coming

.NET MAUI inflight/candidate introduces significant improvements across
all platforms with focus on quality, performance, and developer
experience. This release includes 46 commits with various improvements,
bug fixes, and enhancements.


## Button
- [Android] Implemented material3 support for Button by @Dhivya-SF4094
in #33173
  <details>
  <summary>🔧 Fixes</summary>

- [Implement Material3 support for
Button](#33172)
  </details>

## CollectionView
- [Android] Fix RemainingItemsThresholdReachedCommand not firing when
CollectionView has Header and Footer both defined by @SuthiYuvaraj in
#29618
  <details>
  <summary>🔧 Fixes</summary>

- [Android : RemainingItemsThresholdReachedCommand not firing when
CollectionVew has Header and Footer both
defined](#29588)
  </details>

- [iOS/MacCatalyst] Fix CollectionView ScrollTo for horizontal layouts
by @Shalini-Ashokan in #33853
  <details>
  <summary>🔧 Fixes</summary>

- [[iOS/MacCatalyst] CollectionView ScrollTo does not work with
horizontal Layout](#33852)
  </details>

- [iOS & Mac] Fixed IndicatorView Size doesnt update dynamically by
@SubhikshaSf4851 in #31129
  <details>
  <summary>🔧 Fixes</summary>

- [[iOS, Catalyst] IndicatorView.IndicatorSize does not update
dynamically at runtime](#31064)
  </details>

- [Android] Fix for CollectionView Scrolled event is triggered on the
initial app load. by @BagavathiPerumal in
#33558
  <details>
  <summary>🔧 Fixes</summary>

- [[Android] CollectionView Scrolled event is triggered on the initial
app load.](#33333)
  </details>

- [iOS, Android] Fix for CollectionView IsEnabled=false allows touch
interactions by @praveenkumarkarunanithi in
#31403
  <details>
  <summary>🔧 Fixes</summary>

- [More issues with CollectionView IsEnabled, InputTransparent, Opacity
via Styles and code behind](#19771)
  </details>

- [iOS] Fix VerticalOffset Update When Modifying
CollectionView.ItemsSource While Scrolled by @devanathan-vaithiyanathan
in #34153
  <details>
  <summary>🔧 Fixes</summary>

- [[iOS]VerticalOffset Not Reset to Zero After Clearing ItemSource in
CollectionView](#26798)
  </details>

## DateTimePicker
- [Android] Fix DatePicker MinimumDate/MaximumDate not updating
dynamically by @HarishwaranVijayakumar in
#33687
  <details>
  <summary>🔧 Fixes</summary>

- [[regression/8.0.3] [Android] DatePicker control minimum date
issue](#19256)
- [[Android] DatePicker does not update MinimumDate / MaximumDate in the
Popup when set in the viewmodel after first
opening](#33583)
  </details>

## Drawing
- Android drawable perf by @albyrock87 in
#31567

## Editor
- [Android] Implemented material3 support for Editor by
@SyedAbdulAzeemSF4852 in #33478
  <details>
  <summary>🔧 Fixes</summary>

- [Implement Material3 Support for
Editor](#33476)
  </details>

## Entry
- [iOS, Mac] Fix for CursorPosition not updating when typing into Entry
control by @SyedAbdulAzeemSF4852 in
#30505
  <details>
  <summary>🔧 Fixes</summary>

- [Entry control CursorPosition does not update on TextChanged event
[iOS Maui 8.0.7] ](#20911)
- [CursorPosition not calculated correctly on behaviors events for iOS
devices](#32483)
  </details>

## Flyoutpage
- [Android, Windows] Fix for FlyoutPage toolbar button not updating on
orientation change by @praveenkumarkarunanithi in
#31962
  <details>
  <summary>🔧 Fixes</summary>

- [Flyout page in Android does not show flyout button (burger)
consistently](#24468)
  </details>

- Fix for First Item in CollectionView Overlaps in FlyoutPage.Flyout on
iOS by @praveenkumarkarunanithi in
#29265
  <details>
  <summary>🔧 Fixes</summary>

- [[iOS] CollectionView not rendering first item correctly in
FlyoutPage.Flyout](#29170)
  </details>

## Image
- [Android] Fix excessive memory usage for stream and resource-based
image loading by @Shalini-Ashokan in
#33590
  <details>
  <summary>🔧 Fixes</summary>

- [[Android] Unexpected high Bitmap.ByteCount when loading image via
ImageSource.FromResource() or ImageSource.FromStream() in .NET
MAUI](#33239)
  </details>

- [Android] Fix for Resize method returns an image that has already been
disposed by @SyedAbdulAzeemSF4852 in
#29964
  <details>
  <summary>🔧 Fixes</summary>

- [In GraphicsView, the Resize method returns an image that has already
been disposed](#29961)
- [IIMage.Resize bugged
behaviour](#31103)
  </details>

## Label
- Fixed Label Span font property inheritance when applied via Style by
@SubhikshaSf4851 in #34110
  <details>
  <summary>🔧 Fixes</summary>

- [`Span` does not inherit text styling from `Label` if that styling is
applied using `Style` ](#21326)
  </details>

- [Android] Implemented material3 support for Label by
@SyedAbdulAzeemSF4852 in #33599
  <details>
  <summary>🔧 Fixes</summary>

- [Implement Material3 Support for
Label](#33598)
  </details>

## Map
- [Android] Fix Circle Stroke color is incorrectly updated as Fill
color. by @NirmalKumarYuvaraj in
#33643
  <details>
  <summary>🔧 Fixes</summary>

- [[Android] Circle Stroke color is incorrectly updated as Fill
color.](#33642)
  </details>

## Mediapicker
- [iOS] Fix: invoke MediaPicker completion handler after
DismissViewController by @yuriikyry4enko in
#34250
  <details>
  <summary>🔧 Fixes</summary>

- [[iOS] Media Picker UIImagePickerController closing
issue](#21996)
  </details>

## Navigation
- Fix ContentPage memory leak on Android when using NavigationPage
modally (fixes #33918) by @brunck in
#34117
  <details>
  <summary>🔧 Fixes</summary>

- [[Android] Modal TabbedPage whose tabs are NavigationPage(ContentPage)
is retained after
PopModalAsync()](#33918)
  </details>

## Picker
- [Android] Implement material3 support for TimePicker by
@HarishwaranVijayakumar in #33646
  <details>
  <summary>🔧 Fixes</summary>

- [Implement Material3 support for
TimePicker](#33645)
  </details>

- [Android] Implemented Material3 support for Picker by
@SyedAbdulAzeemSF4852 in #33668
  <details>
  <summary>🔧 Fixes</summary>

- [Implement Material3 support for
Picker](#33665)
  </details>

## RadioButton
- [Android] Implemented material3 support for RadioButton by
@SyedAbdulAzeemSF4852 in #33468
  <details>
  <summary>🔧 Fixes</summary>

- [Implement Material3 Support for
RadioButton](#33467)
  </details>

## Setup
- Clarify MA003 error message by @jeremy-visionaid in
#34067
  <details>
  <summary>🔧 Fixes</summary>

- [MA003 false positive with
9.0.21](#26599)
  </details>

## Shell
- [Android] Fix TabBar FlowDirection not updating dynamically by
@SubhikshaSf4851 in #33091
  <details>
  <summary>🔧 Fixes</summary>

- [[Android, iOS] FlowDirection RTL is not updated dynamically on Shell
TabBar](#32993)
  </details>

- [Android] Fix page not disposed on Shell replace navigation by
@Vignesh-SF3580 in #33426
  <details>
  <summary>🔧 Fixes</summary>

- [[Android] [Shell] replace navigation leaks current
page](#25134)
  </details>

- [Android] Fixed Shell flyout does not disable scrolling when
FlyoutVerticalScrollMode is set to Disabled by @NanthiniMahalingam in
#32734
  <details>
  <summary>🔧 Fixes</summary>

- [[Android] Shell.FlyoutVerticalScrollMode="Disabled" does not disable
scrolling](#32477)
  </details>

## Single Project
- Fix: Throw a clear error when an SVG lacks dimensions instead of a
NullReferenceException by @Shalini-Ashokan in
#33194
  <details>
  <summary>🔧 Fixes</summary>

- [MAUI Fails To Convert Valid SVG Files Into PNG Files (Object
reference not set to an instance of an
object)](#32460)
  </details>

## SwipeView
- [iOS] Fix SwipeView stays open on iOS after updating content by
@devanathan-vaithiyanathan in #31248
  <details>
  <summary>🔧 Fixes</summary>

- [[iOS] - Swipeview with collectionview
issue](#19541)
  </details>

## TabbedPage
- [Windows] Fixed IsEnabled Property not works on Tabs by
@NirmalKumarYuvaraj in #26728
  <details>
  <summary>🔧 Fixes</summary>

- [ShellContent IsEnabledProperty does not
work](#5161)
- [[Windows] Shell Tab IsEnabled Not
Working](#32996)
  </details>

- [Android] Fix NavigationBar overlapping StatusBar when NavigationBar
visibility changes by @Vignesh-SF3580 in
#33359
  <details>
  <summary>🔧 Fixes</summary>

- [[Android] NavigationBar overlaps with StatusBar when mixing
HasNavigationBar=true/false in TabbedPage on Android 15 (API
35)](#33340)
  </details>

## Templates
- Fix for unable to open task using keyboard navigation on windows
platform by @SuthiYuvaraj in #33647
  <details>
  <summary>🔧 Fixes</summary>

- [Unable to open task using keyboard: A11y_.NET maui_User can get all
the insights of
Dashboard_Keyboard](#30787)
  </details>

## TitleView
- Fix for NavigationPage.TitleView does not expand with host window in
iPadOS 26+ by @SuthiYuvaraj in #33088

## Toolbar
- [iOS] Fix toolbar items ignoring BarTextColor on iOS/MacCatalyst 26+
by @Shalini-Ashokan in #34036
  <details>
  <summary>🔧 Fixes</summary>

- [[iOS 26] ToolbarItem color with custom BarTextColor not
working](#33970)
  </details>

- [Android] Fix for ToolbarItem retaining the icon from the previous
page on Android when using NavigationPage. by @BagavathiPerumal in
#32311
  <details>
  <summary>🔧 Fixes</summary>

- [Toolbaritem keeps the icon of the previous page on Android, using
NavigationPage (not shell)](#31727)
  </details>

## WebView
- [Android] Fix WebView in a grid expands beyond it's cell by
@devanathan-vaithiyanathan in #32145
  <details>
  <summary>🔧 Fixes</summary>

- [Android - WebView in a grid expands beyond it's
cell](#32030)
  </details>

## Xaml
- ContentPresenter: Propagate binding context to children with explicit
TemplateBinding by @HarishwaranVijayakumar in
#30880
  <details>
  <summary>🔧 Fixes</summary>

- [Binding context in
ContentPresenter](#23797)
  </details>


<details>
<summary>🔧 Infrastructure (1)</summary>

- [Revert] ContentPresenter: Propagate binding context to children with
explicit TemplateBinding by @Ahamed-Ali in
#34332

</details>

<details>
<summary>🧪 Testing (6)</summary>

- [Testing] Feature Matrix UITest Cases for Shell Flyout Page by
@NafeelaNazhir in #32525
- [Testing] Feature Matrix UITest Cases for Brushes by
@LogishaSelvarajSF4525 in #31833
- [Testing] Feature Matrix UITest Cases for BindableLayout by
@LogishaSelvarajSF4525 in #33108
- [Android] Add UI tests for Material 3 CheckBox by
@HarishwaranVijayakumar in #34126
  <details>
  <summary>🔧 Fixes</summary>

- [[Android] Add UI tests for Material 3
CheckBox](#34125)
  </details>
- [Testing] Feature Matrix UITest Cases for Shell Tabbed Page by
@NafeelaNazhir in #33159
- [Testing] Fixed Test case failure in PR 34294 - [03/2/2026] Candidate
- 1 by @TamilarasanSF4853 in #34334

</details>

<details>
<summary>📦 Other (2)</summary>

- Bumps Syncfusion.Maui.Toolkit dependency to version 1.0.9 by
@PaulAndersonS in #34178
- Fix crash when closing Windows based app when using TitleBar by
@MFinkBK in #34032
  <details>
  <summary>🔧 Fixes</summary>

- [Unhandled exception "Value does not fall within the expected range"
when closing Windows app](#32194)
  </details>

</details>
**Full Changelog**:
main...inflight/candidate
@github-actions github-actions bot locked and limited conversation to collaborators Mar 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-controls-collectionview CollectionView, CarouselView, IndicatorView collectionview-cv2 community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/ios s/agent-approved AI agent recommends approval - PR fix is correct and optimal s/agent-fix-pr-picked AI could not beat the PR fix - PR is the best among all candidates s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix) s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[iOS/MacCatalyst] CollectionView ScrollTo does not work with horizontal Layout

6 participants