Skip to content

[iOS, MacCatalyst] CollectionView: Fix grid spacing updates for first row and column - #34598

Merged
kubaflo merged 7 commits into
dotnet:inflight/currentfrom
KarthikRajaKalaimani:fix-34257-iOS
Jun 23, 2026
Merged

kubaflo merged 7 commits into
dotnet:inflight/currentfrom
KarthikRajaKalaimani:fix-34257-iOS

Conversation

@KarthikRajaKalaimani

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!

Issue Details:

Horizontalspacing / Verticalspacing is not not applied to the first column in GridItemLayout using CollectionView on iOS,Mac and Android platform.

Root Cause:

The grid spacing was not being distributed symmetrically across the active layout implementations, so edge items did not fully participate when spacing changed at runtime. On iOS and MacCatalyst, the active Items2 compositional layout path handled spacing in a way that visually created gaps but did not cause the first column and first row to update consistently with the rest of the grid.

Description of Change:

  • On iOS/MacCatalyst, the fix in LayoutFactory2.cs keeps the existing compositional grid item sizing (FractionalWidth(1f / span) for vertical grids and FractionalHeight(1f / span) for horizontal grids), but changes how spacing is applied. Instead of relying on group.InterItemSpacing, the fix computes half of the requested horizontal and vertical spacing and applies that half-spacing through item.ContentInsets so each item contributes to the gap. It then sets group.InterItemSpacing to 0, keeps section.InterGroupSpacing for spacing between rows or columns, and adds matching half-spacing to section.ContentInsets. This makes the first row/column participate when spacing changes, which fixes the issue where only later rows or columns visually updated.

**Tested the behavior in the following platforms: **

  • Android
  • Windows
  • iOS
  • Mac

Reference:

N/A

Issues Fixed:

Fixes #34257

Screenshots

Before After
Screen.Recording.2026-03-18.at.4.25.45.PM.mov
Screen.Recording.2026-03-18.at.4.21.12.PM.mov

@github-actions

github-actions Bot commented Mar 23, 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 -- 34598

Or

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

@dotnet-policy-service dotnet-policy-service Bot added the community ✨ Community Contribution label Mar 23, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Hey there @@KarthikRajaKalaimani! 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 the partner/syncfusion Issues / PR's with Syncfusion collaboration label Mar 23, 2026
@sheiksyedm
sheiksyedm marked this pull request as ready for review March 24, 2026 06:56
Copilot AI review requested due to automatic review settings March 24, 2026 06:56

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.

Pull request overview

This PR updates the iOS/MacCatalyst Items2 CollectionView compositional grid layout to ensure spacing changes at runtime correctly affect the first row/column in a grid.

Changes:

  • Apply half-spacing via NSCollectionLayoutItem.ContentInsets to distribute inter-item spacing across items.
  • Set group.InterItemSpacing to 0 and rely on item/section insets plus section.InterGroupSpacing to control spacing.

Comment thread src/Controls/src/Core/Handlers/Items2/iOS/LayoutFactory2.cs Outdated
@MauiBot

This comment has been minimized.

3 similar comments
@MauiBot

This comment has been minimized.

@MauiBot

This comment has been minimized.

@MauiBot

This comment has been minimized.

@kubaflo kubaflo 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.

Could you resolve conflicts?

@kubaflo
kubaflo changed the base branch from inflight/current to main March 28, 2026 17:26
@KarthikRajaKalaimani
KarthikRajaKalaimani force-pushed the fix-34257-iOS branch 2 times, most recently from ee00398 to 0c4c8c3 Compare March 30, 2026 13:03
@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 Jun 21, 2026
@MauiBot MauiBot added the s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix) label Jun 21, 2026

@MauiBot MauiBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

AI Review Summary

@KarthikRajaKalaimani — new AI review results are available based on this last commit: 1b9fb5e. To request a fresh review after new comments or commits, comment /review rerun.

Gate Passed Confidence Low Platform iOS


🚀 Next Steps — alternative fix proposed (try-fix-2)

Automated review — alternative fix proposed

The expert-reviewer evaluation compared the PR fix against automatically generated candidates and selected try-fix-2 as the strongest fix.

Why: try-fix-2 passed the supplied iOS regression tests, preserves the Windows test exclusion identified by expert review, and models grid gaps with native external EdgeSpacing instead of item ContentInsets. try-fix-1 failed regression tests, while the raw PR leaves a Windows test-scope issue unresolved.

Please consider applying the candidate diff below (or use it as guidance). Once you push an update, this workflow will re-trigger and re-evaluate.

Candidate diff (try-fix-2)
diff --git a/src/Controls/src/Core/Handlers/Items2/iOS/LayoutFactory2.cs b/src/Controls/src/Core/Handlers/Items2/iOS/LayoutFactory2.cs
index 311d660d72..d2de8790b3 100644
--- a/src/Controls/src/Core/Handlers/Items2/iOS/LayoutFactory2.cs
+++ b/src/Controls/src/Core/Handlers/Items2/iOS/LayoutFactory2.cs
@@ -161,6 +161,19 @@ internal static class LayoutFactory2
 			var itemSize = NSCollectionLayoutSize.Create(itemWidth, itemHeight);
 			// Create the item itself from the size
 			var item = NSCollectionLayoutItem.Create(layoutSize: itemSize);
+			if (columns > 1)
+			{
+				if (scrollDirection == UICollectionViewScrollDirection.Vertical && horizontalItemSpacing > 0)
+				{
+					var halfHorizontalSpacing = NSCollectionLayoutSpacing.CreateFixed(new NFloat(horizontalItemSpacing / 2d));
+					item.EdgeSpacing = NSCollectionLayoutEdgeSpacing.Create(halfHorizontalSpacing, null, halfHorizontalSpacing, null);
+				}
+				else if (scrollDirection == UICollectionViewScrollDirection.Horizontal && verticalItemSpacing > 0)
+				{
+					var halfVerticalSpacing = NSCollectionLayoutSpacing.CreateFixed(new NFloat(verticalItemSpacing / 2d));
+					item.EdgeSpacing = NSCollectionLayoutEdgeSpacing.Create(null, halfVerticalSpacing, null, halfVerticalSpacing);
+				}
+			}
 
 			// Each group of items (for grouped collections) has a size
 			var groupSize = NSCollectionLayoutSize.Create(groupWidth, groupHeight);
@@ -173,20 +186,20 @@ internal static class LayoutFactory2
 				? NSCollectionLayoutGroup.CreateHorizontal(groupSize, item, columns)
 				: NSCollectionLayoutGroup.CreateVertical(groupSize, item, columns);
 
-			if (scrollDirection == UICollectionViewScrollDirection.Vertical)
-				group.InterItemSpacing = NSCollectionLayoutSpacing.CreateFixed(new NFloat(horizontalItemSpacing));
-			else
-				group.InterItemSpacing = NSCollectionLayoutSpacing.CreateFixed(new NFloat(verticalItemSpacing));
-
+			group.InterItemSpacing = NSCollectionLayoutSpacing.CreateFixed(0);
 			// Create our section layout
 			var section = NSCollectionLayoutSection.Create(group: group);
 			if (OperatingSystem.IsIOSVersionAtLeast(26))
 				section.ContentInsetsReference = UIContentInsetsReference.None;
 
 			if (scrollDirection == UICollectionViewScrollDirection.Vertical)
+			{
 				section.InterGroupSpacing = new NFloat(verticalItemSpacing);
+			}
 			else
+			{
 				section.InterGroupSpacing = new NFloat(horizontalItemSpacing);
+			}
 
 
 			section.BoundarySupplementaryItems = CreateSupplementaryItems(
diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue34257.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue34257.cs
index 5b77fd9ebf..60210f3f7f 100644
--- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue34257.cs
+++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue34257.cs
@@ -1,4 +1,4 @@
-#if TEST_FAILS_ON_IOS && TEST_FAILS_ON_CATALYST && TEST_FAILS_ON_WINDOWS //In windows, related issue: https://github.com/dotnet/maui/issues/4715
+#if !WINDOWS // In Windows, related issue: https://github.com/dotnet/maui/issues/4715
 using NUnit.Framework;
 using UITest.Appium;
 using UITest.Core;
@@ -29,11 +29,18 @@ public class Issue34257 : _IssuesUITest
 	[Category(UITestCategories.CollectionView)]
 	public void UpdatingVerticalSpacingShouldResizeBothRows()
 	{
-		var firstColumnBefore = App.WaitForElement("FirstColumnBottomItem").GetRect();
+		var firstColumnTopBefore = App.WaitForElement("FirstColumnTopItem").GetRect();
+		var firstColumnBottomBefore = App.WaitForElement("FirstColumnBottomItem").GetRect();
+		var rowGapBefore = firstColumnBottomBefore.Y - (firstColumnTopBefore.Y + firstColumnTopBefore.Height);
+
 		App.Tap("ApplyVerticalSpacingButton");
 		App.WaitForElement("StatusLabel", "Spacing=40,0");
-		var firstColumnAfter = App.WaitForElement("FirstColumnBottomItem").GetRect();
-		Assert.That(firstColumnBefore.Y, Is.Not.EqualTo(firstColumnAfter.Y), $"Expected the second row to move");
+
+		var firstColumnTopAfter = App.WaitForElement("FirstColumnTopItem").GetRect();
+		var firstColumnBottomAfter = App.WaitForElement("FirstColumnBottomItem").GetRect();
+		var rowGapAfter = firstColumnBottomAfter.Y - (firstColumnTopAfter.Y + firstColumnTopAfter.Height);
+
+		Assert.That(rowGapAfter, Is.GreaterThan(rowGapBefore), $"Expected the gap between rows to increase");
 	}
 }
 #endif
\ No newline at end of file
🗂️ Review Sessions — click to expand
🧪 Gate — Test Before & After Fix

Gate Result: ✅ PASSED

Platform: IOS · Base: main · Merge base: 4567a055

Test Without Fix (expect FAIL) With Fix (expect PASS)
🖥️ Issue34257 Issue34257 ✅ FAIL — 328s ✅ PASS — 126s
🔴 Without fix — 🖥️ Issue34257: FAIL ✅ · 328s
  Determining projects to restore...
  Restored /Users/cloudtest/vss/_work/1/s/src/Graphics/src/Graphics/Graphics.csproj (in 641 ms).
  Restored /Users/cloudtest/vss/_work/1/s/src/Controls/src/BindingSourceGen/Controls.BindingSourceGen.csproj (in 641 ms).
  Restored /Users/cloudtest/vss/_work/1/s/src/Essentials/src/Essentials.csproj (in 4.53 sec).
  Restored /Users/cloudtest/vss/_work/1/s/src/Controls/Foldable/src/Controls.Foldable.csproj (in 5.4 sec).
  Restored /Users/cloudtest/vss/_work/1/s/src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj (in 5.41 sec).
  Restored /Users/cloudtest/vss/_work/1/s/src/Controls/src/Xaml/Controls.Xaml.csproj (in 5.41 sec).
  Restored /Users/cloudtest/vss/_work/1/s/src/Core/maps/src/Maps.csproj (in 4.76 sec).
  Restored /Users/cloudtest/vss/_work/1/s/src/BlazorWebView/src/Maui/Microsoft.AspNetCore.Components.WebView.Maui.csproj (in 5.42 sec).
  Restored /Users/cloudtest/vss/_work/1/s/src/Controls/Maps/src/Controls.Maps.csproj (in 5.42 sec).
  Restored /Users/cloudtest/vss/_work/1/s/src/Controls/src/Core/Controls.Core.csproj (in 5.43 sec).
  Restored /Users/cloudtest/vss/_work/1/s/src/Core/src/Core.csproj (in 5.43 sec).
/Users/cloudtest/vss/_work/1/s/.dotnet/packs/Microsoft.iOS.Sdk.net10.0_26.0/26.0.11017/targets/Xamarin.Shared.Sdk.targets(309,3): warning : RuntimeIdentifier was set on the command line, and will override the value for RuntimeIdentifiers set in the project file. [/Users/cloudtest/vss/_work/1/s/src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj::TargetFramework=net10.0-ios]
  ##vso[build.updatebuildnumber]10.0.90-ci+azdo.14442947
  Graphics -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Graphics/Debug/net10.0-ios26.0/Microsoft.Maui.Graphics.dll
  ##vso[build.updatebuildnumber]10.0.90-ci+azdo.14442947
  Essentials -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Essentials/Debug/net10.0-ios26.0/Microsoft.Maui.Essentials.dll
  ##vso[build.updatebuildnumber]10.0.90-ci+azdo.14442947
  Core -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Core/Debug/net10.0-ios26.0/Microsoft.Maui.dll
  ##vso[build.updatebuildnumber]10.0.90-ci+azdo.14442947
  Maps -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Maps/Debug/net10.0-ios26.0/Microsoft.Maui.Maps.dll
  Controls.BindingSourceGen -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Controls.BindingSourceGen/Debug/netstandard2.0/Microsoft.Maui.Controls.BindingSourceGen.dll
  ##vso[build.updatebuildnumber]10.0.90-ci+azdo.14442947
  Controls.Core -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Controls.Core/Debug/net10.0-ios26.0/Microsoft.Maui.Controls.dll
  ##vso[build.updatebuildnumber]10.0.90-ci+azdo.14442947
  ##vso[build.updatebuildnumber]10.0.90-ci+azdo.14442947
  ##vso[build.updatebuildnumber]10.0.90-ci+azdo.14442947
  Microsoft.AspNetCore.Components.WebView.Maui -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Microsoft.AspNetCore.Components.WebView.Maui/Debug/net10.0-ios26.0/Microsoft.AspNetCore.Components.WebView.Maui.dll
  ##vso[build.updatebuildnumber]10.0.90-ci+azdo.14442947
  Controls.Xaml -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Controls.Xaml/Debug/net10.0-ios26.0/Microsoft.Maui.Controls.Xaml.dll
  Controls.Foldable -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Controls.Foldable/Debug/net10.0-ios26.0/Microsoft.Maui.Controls.Foldable.dll
  Controls.Maps -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Controls.Maps/Debug/net10.0-ios26.0/Microsoft.Maui.Controls.Maps.dll
  Detected signing identity:
    Code Signing Key: "" (-)
    Provisioning Profile: "" () - no entitlements
    Bundle Id: com.microsoft.maui.uitests
    App Id: com.microsoft.maui.uitests
  Controls.TestCases.HostApp -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Controls.TestCases.HostApp/Debug/net10.0-ios/iossimulator-arm64/Controls.TestCases.HostApp.dll
  Optimizing assemblies for size may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
  Optimizing assemblies for size. This process might take a while.

Build succeeded.

/Users/cloudtest/vss/_work/1/s/.dotnet/packs/Microsoft.iOS.Sdk.net10.0_26.0/26.0.11017/targets/Xamarin.Shared.Sdk.targets(309,3): warning : RuntimeIdentifier was set on the command line, and will override the value for RuntimeIdentifiers set in the project file. [/Users/cloudtest/vss/_work/1/s/src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj::TargetFramework=net10.0-ios]
    1 Warning(s)
    0 Error(s)

Time Elapsed 00:03:03.86
  Determining projects to restore...
  Restored /Users/cloudtest/vss/_work/1/s/src/Essentials/src/Essentials.csproj (in 788 ms).
  Restored /Users/cloudtest/vss/_work/1/s/src/Controls/src/BindingSourceGen/Controls.BindingSourceGen.csproj (in 787 ms).
  Restored /Users/cloudtest/vss/_work/1/s/src/Graphics/src/Graphics/Graphics.csproj (in 789 ms).
  Restored /Users/cloudtest/vss/_work/1/s/src/TestUtils/src/UITest.Core/UITest.Core.csproj (in 47 ms).
  Restored /Users/cloudtest/vss/_work/1/s/src/TestUtils/src/VisualTestUtils/VisualTestUtils.csproj (in 51 ms).
  Restored /Users/cloudtest/vss/_work/1/s/src/Controls/tests/CustomAttributes/Controls.CustomAttributes.csproj (in 2 ms).
  Restored /Users/cloudtest/vss/_work/1/s/src/Controls/src/Core/Controls.Core.csproj (in 873 ms).
  Restored /Users/cloudtest/vss/_work/1/s/src/Core/src/Core.csproj (in 892 ms).
  Restored /Users/cloudtest/vss/_work/1/s/src/TestUtils/src/UITest.NUnit/UITest.NUnit.csproj (in 1.45 sec).
  Restored /Users/cloudtest/vss/_work/1/s/src/TestUtils/src/UITest.Appium/UITest.Appium.csproj (in 2.02 sec).
  Restored /Users/cloudtest/vss/_work/1/s/src/TestUtils/src/UITest.Analyzers/UITest.Analyzers.csproj (in 2.66 sec).
  Restored /Users/cloudtest/vss/_work/1/s/src/TestUtils/src/VisualTestUtils.MagickNet/VisualTestUtils.MagickNet.csproj (in 2.5 sec).
  Restored /Users/cloudtest/vss/_work/1/s/src/Controls/tests/TestCases.iOS.Tests/Controls.TestCases.iOS.Tests.csproj (in 3.35 sec).
  ##vso[build.updatebuildnumber]10.0.90-ci+azdo.14442947
  Controls.CustomAttributes -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Controls.CustomAttributes/Debug/net10.0/Controls.CustomAttributes.dll
  Graphics -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Graphics/Debug/net10.0/Microsoft.Maui.Graphics.dll
  ##vso[build.updatebuildnumber]10.0.90-ci+azdo.14442947
  Essentials -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Essentials/Debug/net10.0/Microsoft.Maui.Essentials.dll
  ##vso[build.updatebuildnumber]10.0.90-ci+azdo.14442947
  Core -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Core/Debug/net10.0/Microsoft.Maui.dll
  Controls.BindingSourceGen -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Controls.BindingSourceGen/Debug/netstandard2.0/Microsoft.Maui.Controls.BindingSourceGen.dll
  ##vso[build.updatebuildnumber]10.0.90-ci+azdo.14442947
  Controls.Core -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Controls.Core/Debug/net10.0/Microsoft.Maui.Controls.dll
  UITest.Core -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/UITest.Core/Debug/net10.0/UITest.Core.dll
  VisualTestUtils -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/VisualTestUtils/Debug/netstandard2.0/VisualTestUtils.dll
  UITest.NUnit -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/UITest.NUnit/Debug/net10.0/UITest.NUnit.dll
  VisualTestUtils.MagickNet -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/VisualTestUtils.MagickNet/Debug/netstandard2.0/VisualTestUtils.MagickNet.dll
  UITest.Appium -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/UITest.Appium/Debug/net10.0/UITest.Appium.dll
  UITest.Analyzers -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/UITest.Analyzers/Debug/netstandard2.0/UITest.Analyzers.dll
  Controls.TestCases.iOS.Tests -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Controls.TestCases.iOS.Tests/Debug/net10.0/Controls.TestCases.iOS.Tests.dll
Test run for /Users/cloudtest/vss/_work/1/s/artifacts/bin/Controls.TestCases.iOS.Tests/Debug/net10.0/Controls.TestCases.iOS.Tests.dll (.NETCoreApp,Version=v10.0)
VSTest version 18.0.1 (arm64)

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.8.2+699d445a1a (64-bit .NET 10.0.0)
[xUnit.net 00:00:00.07]   Discovering: Controls.TestCases.iOS.Tests
[xUnit.net 00:00:00.21]   Discovered:  Controls.TestCases.iOS.Tests
NUnit Adapter 4.5.0.0: Test execution started
Running selected tests in /Users/cloudtest/vss/_work/1/s/artifacts/bin/Controls.TestCases.iOS.Tests/Debug/net10.0/Controls.TestCases.iOS.Tests.dll
   NUnit3TestExecutor discovered 2 of 2 NUnit test cases using Current Discovery mode, Non-Explicit run
>>>>> 6/21/2026 12:26:11 PM FixtureSetup for Issue34257(iOS)
>>>>> 6/21/2026 12:26:16 PM UpdatingHorizontalSpacingShouldResizeBothColumns Start
>>>>> 6/21/2026 12:26:17 PM UpdatingHorizontalSpacingShouldResizeBothColumns Stop
>>>>> 6/21/2026 12:26:17 PM Log types: syslog, crashlog, performance, safariConsole, safariNetwork, server
  Failed UpdatingHorizontalSpacingShouldResizeBothColumns [1 s]
  Error Message:
     Expected the first column to move
Assert.That(firstColumnBefore.X, Is.Not.EqualTo(firstColumnAfter.X))
  Expected: not equal to 17
  But was:  17

  Stack Trace:
     at Microsoft.Maui.TestCases.Tests.Issues.Issue34257.UpdatingHorizontalSpacingShouldResizeBothColumns() in /_/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue34257.cs:line 24

1)    at Microsoft.Maui.TestCases.Tests.Issues.Issue34257.UpdatingHorizontalSpacingShouldResizeBothColumns() in /_/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue34257.cs:line 24


>>>>> 6/21/2026 12:26:18 PM UpdatingVerticalSpacingShouldResizeBothRows Start
>>>>> 6/21/2026 12:26:19 PM UpdatingVerticalSpacingShouldResizeBothRows Stop
  Passed UpdatingVerticalSpacingShouldResizeBothRows [1 s]
NUnit Adapter 4.5.0.0: Test execution complete
Results File: /Users/cloudtest/vss/_work/1/s/CustomAgentLogsTmp/UITests/TestResults/Issue34257.trx

Total tests: 2
Test Run Failed.
     Passed: 1
     Failed: 1
 Total time: 1.5330 Minutes
>>> TRX_RESULT_FILE: /Users/cloudtest/vss/_work/1/s/CustomAgentLogsTmp/UITests/TestResults/Issue34257.trx

🟢 With fix — 🖥️ Issue34257: PASS ✅ · 126s
  Determining projects to restore...
  Restored /Users/cloudtest/vss/_work/1/s/src/Controls/src/BindingSourceGen/Controls.BindingSourceGen.csproj (in 406 ms).
  Restored /Users/cloudtest/vss/_work/1/s/src/Graphics/src/Graphics/Graphics.csproj (in 423 ms).
  Restored /Users/cloudtest/vss/_work/1/s/src/Essentials/src/Essentials.csproj (in 378 ms).
  Restored /Users/cloudtest/vss/_work/1/s/src/Controls/src/Core/Controls.Core.csproj (in 469 ms).
  Restored /Users/cloudtest/vss/_work/1/s/src/Core/src/Core.csproj (in 487 ms).
  6 of 11 projects are up-to-date for restore.
/Users/cloudtest/vss/_work/1/s/.dotnet/packs/Microsoft.iOS.Sdk.net10.0_26.0/26.0.11017/targets/Xamarin.Shared.Sdk.targets(309,3): warning : RuntimeIdentifier was set on the command line, and will override the value for RuntimeIdentifiers set in the project file. [/Users/cloudtest/vss/_work/1/s/src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj::TargetFramework=net10.0-ios]
  ##vso[build.updatebuildnumber]10.0.90-ci+azdo.14442947
  Graphics -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Graphics/Debug/net10.0-ios26.0/Microsoft.Maui.Graphics.dll
  ##vso[build.updatebuildnumber]10.0.90-ci+azdo.14442947
  Essentials -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Essentials/Debug/net10.0-ios26.0/Microsoft.Maui.Essentials.dll
  ##vso[build.updatebuildnumber]10.0.90-ci+azdo.14442947
  Core -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Core/Debug/net10.0-ios26.0/Microsoft.Maui.dll
  ##vso[build.updatebuildnumber]10.0.90-ci+azdo.14442947
  Maps -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Maps/Debug/net10.0-ios26.0/Microsoft.Maui.Maps.dll
  Controls.BindingSourceGen -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Controls.BindingSourceGen/Debug/netstandard2.0/Microsoft.Maui.Controls.BindingSourceGen.dll
  ##vso[build.updatebuildnumber]10.0.90-ci+azdo.14442947
  Controls.Core -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Controls.Core/Debug/net10.0-ios26.0/Microsoft.Maui.Controls.dll
  ##vso[build.updatebuildnumber]10.0.90-ci+azdo.14442947
  ##vso[build.updatebuildnumber]10.0.90-ci+azdo.14442947
  ##vso[build.updatebuildnumber]10.0.90-ci+azdo.14442947
  Microsoft.AspNetCore.Components.WebView.Maui -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Microsoft.AspNetCore.Components.WebView.Maui/Debug/net10.0-ios26.0/Microsoft.AspNetCore.Components.WebView.Maui.dll
  Controls.Xaml -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Controls.Xaml/Debug/net10.0-ios26.0/Microsoft.Maui.Controls.Xaml.dll
  Controls.Foldable -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Controls.Foldable/Debug/net10.0-ios26.0/Microsoft.Maui.Controls.Foldable.dll
  ##vso[build.updatebuildnumber]10.0.90-ci+azdo.14442947
  Controls.Maps -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Controls.Maps/Debug/net10.0-ios26.0/Microsoft.Maui.Controls.Maps.dll
  Detected signing identity:
    Code Signing Key: "" (-)
    Provisioning Profile: "" () - no entitlements
    Bundle Id: com.microsoft.maui.uitests
    App Id: com.microsoft.maui.uitests
  Controls.TestCases.HostApp -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Controls.TestCases.HostApp/Debug/net10.0-ios/iossimulator-arm64/Controls.TestCases.HostApp.dll
  Optimizing assemblies for size may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
  Optimizing assemblies for size. This process might take a while.

Build succeeded.

/Users/cloudtest/vss/_work/1/s/.dotnet/packs/Microsoft.iOS.Sdk.net10.0_26.0/26.0.11017/targets/Xamarin.Shared.Sdk.targets(309,3): warning : RuntimeIdentifier was set on the command line, and will override the value for RuntimeIdentifiers set in the project file. [/Users/cloudtest/vss/_work/1/s/src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj::TargetFramework=net10.0-ios]
    1 Warning(s)
    0 Error(s)

Time Elapsed 00:01:04.33
  Determining projects to restore...
  Restored /Users/cloudtest/vss/_work/1/s/src/Controls/src/BindingSourceGen/Controls.BindingSourceGen.csproj (in 432 ms).
  Restored /Users/cloudtest/vss/_work/1/s/src/Graphics/src/Graphics/Graphics.csproj (in 435 ms).
  Restored /Users/cloudtest/vss/_work/1/s/src/Essentials/src/Essentials.csproj (in 402 ms).
  Restored /Users/cloudtest/vss/_work/1/s/src/Core/src/Core.csproj (in 468 ms).
  Restored /Users/cloudtest/vss/_work/1/s/src/Controls/src/Core/Controls.Core.csproj (in 485 ms).
  8 of 13 projects are up-to-date for restore.
  Controls.CustomAttributes -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Controls.CustomAttributes/Debug/net10.0/Controls.CustomAttributes.dll
  ##vso[build.updatebuildnumber]10.0.90-ci+azdo.14442947
  Graphics -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Graphics/Debug/net10.0/Microsoft.Maui.Graphics.dll
  ##vso[build.updatebuildnumber]10.0.90-ci+azdo.14442947
  Essentials -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Essentials/Debug/net10.0/Microsoft.Maui.Essentials.dll
  ##vso[build.updatebuildnumber]10.0.90-ci+azdo.14442947
  Core -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Core/Debug/net10.0/Microsoft.Maui.dll
  Controls.BindingSourceGen -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Controls.BindingSourceGen/Debug/netstandard2.0/Microsoft.Maui.Controls.BindingSourceGen.dll
  ##vso[build.updatebuildnumber]10.0.90-ci+azdo.14442947
  Controls.Core -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Controls.Core/Debug/net10.0/Microsoft.Maui.Controls.dll
  VisualTestUtils -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/VisualTestUtils/Debug/netstandard2.0/VisualTestUtils.dll
  UITest.Core -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/UITest.Core/Debug/net10.0/UITest.Core.dll
  VisualTestUtils.MagickNet -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/VisualTestUtils.MagickNet/Debug/netstandard2.0/VisualTestUtils.MagickNet.dll
  UITest.NUnit -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/UITest.NUnit/Debug/net10.0/UITest.NUnit.dll
  UITest.Appium -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/UITest.Appium/Debug/net10.0/UITest.Appium.dll
  UITest.Analyzers -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/UITest.Analyzers/Debug/netstandard2.0/UITest.Analyzers.dll
  Controls.TestCases.iOS.Tests -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Controls.TestCases.iOS.Tests/Debug/net10.0/Controls.TestCases.iOS.Tests.dll
Test run for /Users/cloudtest/vss/_work/1/s/artifacts/bin/Controls.TestCases.iOS.Tests/Debug/net10.0/Controls.TestCases.iOS.Tests.dll (.NETCoreApp,Version=v10.0)
VSTest version 18.0.1 (arm64)

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.8.2+699d445a1a (64-bit .NET 10.0.0)
[xUnit.net 00:00:00.06]   Discovering: Controls.TestCases.iOS.Tests
[xUnit.net 00:00:00.20]   Discovered:  Controls.TestCases.iOS.Tests
NUnit Adapter 4.5.0.0: Test execution started
Running selected tests in /Users/cloudtest/vss/_work/1/s/artifacts/bin/Controls.TestCases.iOS.Tests/Debug/net10.0/Controls.TestCases.iOS.Tests.dll
   NUnit3TestExecutor discovered 2 of 2 NUnit test cases using Current Discovery mode, Non-Explicit run
>>>>> 6/21/2026 12:28:18 PM FixtureSetup for Issue34257(iOS)
>>>>> 6/21/2026 12:28:23 PM UpdatingHorizontalSpacingShouldResizeBothColumns Start
>>>>> 6/21/2026 12:28:24 PM UpdatingHorizontalSpacingShouldResizeBothColumns Stop
>>>>> 6/21/2026 12:28:24 PM UpdatingVerticalSpacingShouldResizeBothRows Start
  Passed UpdatingHorizontalSpacingShouldResizeBothColumns [995 ms]
>>>>> 6/21/2026 12:28:25 PM UpdatingVerticalSpacingShouldResizeBothRows Stop
  Passed UpdatingVerticalSpacingShouldResizeBothRows [1 s]
NUnit Adapter 4.5.0.0: Test execution complete
Results File: /Users/cloudtest/vss/_work/1/s/CustomAgentLogsTmp/UITests/TestResults/Issue34257.trx

Test Run Successful.
Total tests: 2
     Passed: 2
 Total time: 26.4531 Seconds
>>> TRX_RESULT_FILE: /Users/cloudtest/vss/_work/1/s/CustomAgentLogsTmp/UITests/TestResults/Issue34257.trx

📁 Fix files reverted (1 files)
  • src/Controls/src/Core/Handlers/Items2/iOS/LayoutFactory2.cs

🛫 Pre-Flight — Context & Validation

Issue: #34257 - CollectionView vertical grid item spacing updates all rows and columns
PR: #34598 - local squashed PR branch pr-review-34598
Platforms Affected: iOS, MacCatalyst (implementation); UI test also affects Windows if guard remains removed
Files Changed: 1 implementation, 1 test

Key Findings

  • Local PR branch changes src/Controls/src/Core/Handlers/Items2/iOS/LayoutFactory2.cs, the active CollectionView Items2 handler path for iOS/MacCatalyst.
  • The PR fix replaces native group inter-item spacing for grid cross-axis spacing with per-item content insets, and leaves main-axis spacing on section.InterGroupSpacing.
  • The regression test Issue34257 is re-enabled and strengthens vertical spacing verification by measuring the row gap.
  • GitHub API/CLI context could not be fetched because gh is unauthenticated in this environment; pre-flight continued from the local squashed PR branch and local diff.

Code Review Summary

Verdict: NEEDS_CHANGES
Confidence: low
Errors: 1 | Warnings: 0 | Suggestions: 0

Key code review findings:

  • src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue34257.cs:1 — The Windows skip was removed even though the implementation fix only targets iOS/MacCatalyst Items2; the prior guard documented a Windows-related issue.

Fix Candidates

# Source Approach Test Result Files Changed Notes
PR PR #34598 Use per-item half content insets for grid cross-axis spacing and section.InterGroupSpacing for main-axis spacing ✅ PASSED (Gate) LayoutFactory2.cs, Issue34257.cs Original PR; gate result supplied by caller

🔬 Code Review — Deep Analysis

Code Review — PR #34598

Independent Assessment

What this changes: iOS/MacCatalyst Items2 grid spacing now uses per-item half insets for cross-axis gaps and section.InterGroupSpacing for row/column groups. The UI test is re-enabled and strengthened for vertical row-gap verification.
Inferred motivation: Fix CollectionView grid spacing updates so first row/column visibly participate when spacing changes at runtime.

Reconciliation with PR Narrative

Author claims: Fixes iOS/MacCatalyst CollectionView grid spacing for issue #34257.
Agreement/disagreement: Mostly agrees. The description still mentions matching section.ContentInsets, but current code correctly does not add section insets.

Prior Review Reconciliation

Prior ❌ Error Finding Source Status Evidence
Missing columns > 1 guard for item insets MauiBot inline ✅ Fixed LayoutFactory2.cs:167/171 now guards with columns > 1.
Section content insets add outer whitespace MauiBot inline ✅ Fixed No section.ContentInsets assignment remains in CreateGridLayout.

Also noted: prior platform-scope warning remains unresolved.

Blast Radius Assessment

  • Runs for all instances: No; only iOS/MacCatalyst Items2 GridItemsLayout.
  • Startup impact: No.
  • Static/shared state: No.
  • Test blast radius: Yes; removing the compile guard enables the test beyond the fixed iOS/MacCatalyst scope.

CI Status

  • Required-check result: unavailable; gh pr checks --required failed because GitHub CLI is unauthenticated.
  • Classification: undetermined.
  • Action taken: confidence capped low; not LGTM.

Findings

❌ Error — Windows test guard was removed without a Windows fix

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue34257.cs:1

The previous guard explicitly excluded Windows with a comment referencing #4715. This PR only changes Items2/iOS/LayoutFactory2.cs, so Windows still uses a different handler path and the known Windows issue is not addressed. Removing the whole guard enables this UI test on Windows and can reintroduce the known failure. Keep the Windows skip while re-enabling iOS/MacCatalyst.

Failure-Mode Probing

  • Single-column grid with spacing: guarded by columns > 1, so item content is not narrowed unnecessarily.
  • First/last row outer padding: no section insets are added, so row spacing stays between groups.
  • Windows UI run: test now compiles/runs without a Windows fix, so known failure risk remains.

Verdict: NEEDS_CHANGES

Confidence: low
Summary: The iOS/MacCatalyst layout fix looks sound, and prior layout issues appear addressed. However, the test change removes a documented Windows exclusion without fixing Windows, so this should be corrected before merge.


🛠️ Fix — Analysis & Comparison

Fix Candidates

# Source Approach Test Result Files Changed Notes
1 try-fix-1 Spacing-aware absolute cross-axis sizing with native group.InterItemSpacing ❌ Fail 2 files Vertical test passed; horizontal failed because first column X stayed fixed (Expected: not equal to 17).
2 try-fix-2 Native NSCollectionLayoutItem.EdgeSpacing with zero group inter-item spacing ✅ Pass 2 files Passed both Issue34257 iOS UI tests; uses external native item spacing instead of content insets.
PR PR #34598 Per-item half ContentInsets with zero group inter-item spacing ✅ PASSED (Gate) 2 files Original PR; gate result supplied by caller.

Cross-Pollination

Model Round New Ideas? Details
maui-expert-reviewer 1 Yes Proposed spacing-aware absolute cross-axis sizing; failed horizontal assertion.
maui-expert-reviewer 2 Yes Proposed native item edge spacing after learning from candidate 1 failure; passed.

Exhausted: No — stopped because candidate 2 passed the iOS regression tests and is meaningfully different from the PR fix.
Selected Fix: Candidate #2 — It preserves native external spacing semantics (EdgeSpacing) while passing the same iOS regression tests; this is cleaner than using content insets as a spacing surrogate, though it should still preserve the Windows test guard noted in pre-flight.


📝 Recommended PR Title & Description

Assessment: ✏️ Recommend updating — the current description accurately explains the submitted PR's ContentInsets approach, but the winning candidate uses native NSCollectionLayoutItem.EdgeSpacing and restores the Windows test guard.

Recommended title

[iOS, MacCatalyst] CollectionView: Fix grid spacing updates for first row and column

Recommended description

### Issue Details:

HorizontalSpacing / VerticalSpacing is not applied consistently to the first column and first row in `GridItemsLayout` when using `CollectionView`. This PR addresses the active iOS/MacCatalyst Items2 compositional layout path.

### Root Cause:

The active iOS/MacCatalyst Items2 compositional grid layout used `group.InterItemSpacing` for cross-axis spacing. That visually created gaps between later items, but edge items did not fully participate when spacing changed at runtime, so the first column and first row did not update consistently with the rest of the grid.

### Description of Change:

- On iOS/MacCatalyst, `LayoutFactory2.cs` keeps the existing compositional grid item sizing (`FractionalWidth(1f / span)` for vertical grids and `FractionalHeight(1f / span)` for horizontal grids), but changes how cross-axis spacing is applied.
- Instead of relying on `group.InterItemSpacing`, the fix computes half of the requested horizontal or vertical spacing and applies it as native external `NSCollectionLayoutItem.EdgeSpacing`.
- `group.InterItemSpacing` is set to `0`, while `section.InterGroupSpacing` continues to represent spacing between rows or columns on the main axis.
- The `Issue34257` UI test now verifies that vertical spacing increases the actual row gap, and remains excluded on Windows because the implementation change does not target WinUI and the existing Windows-related issue is tracked by #4715.

**Tested the behavior in the following platforms:**

- [ ] Android
- [ ] Windows
- [x] iOS
- [x] Mac

### Reference:

N/A

### Issues Fixed:

Fixes #34257

### Screenshots
| Before  | After  |
|---------|--------|
|   <Video src="https://github.com/user-attachments/assets/578dda69-1d60-474c-a6d8-23b3f9d29a50" Width="300" Height="600">   |    <Video src="https://github.com/user-attachments/assets/7f3826e6-5922-4b6f-a6b9-de581b7db6c3" Width="300" Height="600">  |

🏁 Report — Final Recommendation

Comparative Candidate Report — PR #34598

Candidates

Rank Candidate Regression result Assessment
1 try-fix-2 ✅ Pass Best candidate. It uses native NSCollectionLayoutItem.EdgeSpacing for external cross-axis half-spacing, keeps group.InterItemSpacing at zero, preserves main-axis section.InterGroupSpacing, and restores the Windows test exclusion. This matches UIKit spacing semantics better than padding item content.
2 pr-plus-reviewer ✅ Pass-equivalent Addresses the expert reviewer's actionable feedback by restoring the Windows test guard while keeping the PR's ContentInsets implementation. It is acceptable for the supplied iOS regression, but content insets model spacing as internal padding rather than external item spacing.
3 pr ✅ Pass Fixes the iOS regression, but leaves the expert review finding unresolved: the test is enabled on Windows despite no Windows implementation change and a documented Windows issue.
4 try-fix-1 ❌ Fail Ranked below all passing candidates. The absolute cross-axis sizing approach kept the first column's X position fixed, failing UpdatingHorizontalSpacingShouldResizeBothColumns.

Winner

Winner: try-fix-2

try-fix-2 is the single strongest candidate because it passes the supplied iOS regression tests, keeps Windows excluded from the UI test until a Windows fix exists, and represents grid gaps with native external EdgeSpacing instead of shrinking item content with ContentInsets. pr-plus-reviewer fixes the reviewer's test-scope issue, but the EdgeSpacing approach is cleaner and less likely to alter item interior layout.

@MauiBot MauiBot removed the s/agent-review-in-progress AI review is currently running for this PR label Jun 21, 2026
@KarthikRajaKalaimani KarthikRajaKalaimani changed the title [iOS, MacCatalyst] Fix CollectionView grid spacing updates for first row and column [iOS, MacCatalyst] CollectionView: Fix grid spacing updates for first row and column Jun 22, 2026
@kubaflo

kubaflo commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 3 pipeline(s).

@kubaflo
kubaflo changed the base branch from main to inflight/current June 23, 2026 14:08
@kubaflo
kubaflo merged commit 6f40d85 into dotnet:inflight/current Jun 23, 2026
149 of 162 checks passed
@github-actions github-actions Bot added this to the .NET 10 SR9 milestone Jun 23, 2026
kubaflo pushed a commit that referenced this pull request Jun 25, 2026
… row and column (#34598)

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

### Issue Details:

Horizontalspacing / Verticalspacing is not not applied to the first
column in GridItemLayout using CollectionView on iOS,Mac and Android
platform.
        
### Root Cause:

The grid spacing was not being distributed symmetrically across the
active layout implementations, so edge items did not fully participate
when spacing changed at runtime. On iOS and MacCatalyst, the active
Items2 compositional layout path handled spacing in a way that visually
created gaps but did not cause the first column and first row to update
consistently with the rest of the grid.

### Description of Change:

- On iOS/MacCatalyst, the fix in LayoutFactory2.cs keeps the existing
compositional grid item sizing (FractionalWidth(1f / span) for vertical
grids and FractionalHeight(1f / span) for horizontal grids), but changes
how spacing is applied. Instead of relying on group.InterItemSpacing,
the fix computes half of the requested horizontal and vertical spacing
and applies that half-spacing through item.ContentInsets so each item
contributes to the gap. It then sets group.InterItemSpacing to 0, keeps
section.InterGroupSpacing for spacing between rows or columns, and adds
matching half-spacing to section.ContentInsets. This makes the first
row/column participate when spacing changes, which fixes the issue where
only later rows or columns visually updated.

**Tested the behavior in the following platforms: **

- [ ] Android
- [ ] Windows
- [x] iOS
- [x] Mac

### Reference:

N/A

### Issues Fixed:

Fixes  #34257      

### Screenshots
| Before  | After  |
|---------|--------|
| <Video
src="https://github.com/user-attachments/assets/578dda69-1d60-474c-a6d8-23b3f9d29a50"
Width="300" Height="600"> | <Video
src="https://github.com/user-attachments/assets/7f3826e6-5922-4b6f-a6b9-de581b7db6c3"
Width="300" Height="600"> |
kubaflo pushed a commit that referenced this pull request Jul 3, 2026
… row and column (#34598)

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

### Issue Details:

Horizontalspacing / Verticalspacing is not not applied to the first
column in GridItemLayout using CollectionView on iOS,Mac and Android
platform.
        
### Root Cause:

The grid spacing was not being distributed symmetrically across the
active layout implementations, so edge items did not fully participate
when spacing changed at runtime. On iOS and MacCatalyst, the active
Items2 compositional layout path handled spacing in a way that visually
created gaps but did not cause the first column and first row to update
consistently with the rest of the grid.

### Description of Change:

- On iOS/MacCatalyst, the fix in LayoutFactory2.cs keeps the existing
compositional grid item sizing (FractionalWidth(1f / span) for vertical
grids and FractionalHeight(1f / span) for horizontal grids), but changes
how spacing is applied. Instead of relying on group.InterItemSpacing,
the fix computes half of the requested horizontal and vertical spacing
and applies that half-spacing through item.ContentInsets so each item
contributes to the gap. It then sets group.InterItemSpacing to 0, keeps
section.InterGroupSpacing for spacing between rows or columns, and adds
matching half-spacing to section.ContentInsets. This makes the first
row/column participate when spacing changes, which fixes the issue where
only later rows or columns visually updated.

**Tested the behavior in the following platforms: **

- [ ] Android
- [ ] Windows
- [x] iOS
- [x] Mac

### Reference:

N/A

### Issues Fixed:

Fixes  #34257      

### Screenshots
| Before  | After  |
|---------|--------|
| <Video
src="https://github.com/user-attachments/assets/578dda69-1d60-474c-a6d8-23b3f9d29a50"
Width="300" Height="600"> | <Video
src="https://github.com/user-attachments/assets/7f3826e6-5922-4b6f-a6b9-de581b7db6c3"
Width="300" Height="600"> |
@kubaflo kubaflo mentioned this pull request Jul 6, 2026
kubaflo pushed a commit that referenced this pull request Jul 6, 2026
… row and column (#34598)

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

### Issue Details:

Horizontalspacing / Verticalspacing is not not applied to the first
column in GridItemLayout using CollectionView on iOS,Mac and Android
platform.
        
### Root Cause:

The grid spacing was not being distributed symmetrically across the
active layout implementations, so edge items did not fully participate
when spacing changed at runtime. On iOS and MacCatalyst, the active
Items2 compositional layout path handled spacing in a way that visually
created gaps but did not cause the first column and first row to update
consistently with the rest of the grid.

### Description of Change:

- On iOS/MacCatalyst, the fix in LayoutFactory2.cs keeps the existing
compositional grid item sizing (FractionalWidth(1f / span) for vertical
grids and FractionalHeight(1f / span) for horizontal grids), but changes
how spacing is applied. Instead of relying on group.InterItemSpacing,
the fix computes half of the requested horizontal and vertical spacing
and applies that half-spacing through item.ContentInsets so each item
contributes to the gap. It then sets group.InterItemSpacing to 0, keeps
section.InterGroupSpacing for spacing between rows or columns, and adds
matching half-spacing to section.ContentInsets. This makes the first
row/column participate when spacing changes, which fixes the issue where
only later rows or columns visually updated.

**Tested the behavior in the following platforms: **

- [ ] Android
- [ ] Windows
- [x] iOS
- [x] Mac

### Reference:

N/A

### Issues Fixed:

Fixes  #34257      

### Screenshots
| Before  | After  |
|---------|--------|
| <Video
src="https://github.com/user-attachments/assets/578dda69-1d60-474c-a6d8-23b3f9d29a50"
Width="300" Height="600"> | <Video
src="https://github.com/user-attachments/assets/7f3826e6-5922-4b6f-a6b9-de581b7db6c3"
Width="300" Height="600"> |
PureWeen pushed a commit that referenced this pull request Jul 7, 2026
… row and column (#34598)

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

### Issue Details:

Horizontalspacing / Verticalspacing is not not applied to the first
column in GridItemLayout using CollectionView on iOS,Mac and Android
platform.
        
### Root Cause:

The grid spacing was not being distributed symmetrically across the
active layout implementations, so edge items did not fully participate
when spacing changed at runtime. On iOS and MacCatalyst, the active
Items2 compositional layout path handled spacing in a way that visually
created gaps but did not cause the first column and first row to update
consistently with the rest of the grid.

### Description of Change:

- On iOS/MacCatalyst, the fix in LayoutFactory2.cs keeps the existing
compositional grid item sizing (FractionalWidth(1f / span) for vertical
grids and FractionalHeight(1f / span) for horizontal grids), but changes
how spacing is applied. Instead of relying on group.InterItemSpacing,
the fix computes half of the requested horizontal and vertical spacing
and applies that half-spacing through item.ContentInsets so each item
contributes to the gap. It then sets group.InterItemSpacing to 0, keeps
section.InterGroupSpacing for spacing between rows or columns, and adds
matching half-spacing to section.ContentInsets. This makes the first
row/column participate when spacing changes, which fixes the issue where
only later rows or columns visually updated.

**Tested the behavior in the following platforms: **

- [ ] Android
- [ ] Windows
- [x] iOS
- [x] Mac

### Reference:

N/A

### Issues Fixed:

Fixes  #34257      

### Screenshots
| Before  | After  |
|---------|--------|
| <Video
src="https://github.com/user-attachments/assets/578dda69-1d60-474c-a6d8-23b3f9d29a50"
Width="300" Height="600"> | <Video
src="https://github.com/user-attachments/assets/7f3826e6-5922-4b6f-a6b9-de581b7db6c3"
Width="300" Height="600"> |
PureWeen pushed a commit that referenced this pull request Jul 7, 2026
… row and column (#34598)

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

### Issue Details:

Horizontalspacing / Verticalspacing is not not applied to the first
column in GridItemLayout using CollectionView on iOS,Mac and Android
platform.
        
### Root Cause:

The grid spacing was not being distributed symmetrically across the
active layout implementations, so edge items did not fully participate
when spacing changed at runtime. On iOS and MacCatalyst, the active
Items2 compositional layout path handled spacing in a way that visually
created gaps but did not cause the first column and first row to update
consistently with the rest of the grid.

### Description of Change:

- On iOS/MacCatalyst, the fix in LayoutFactory2.cs keeps the existing
compositional grid item sizing (FractionalWidth(1f / span) for vertical
grids and FractionalHeight(1f / span) for horizontal grids), but changes
how spacing is applied. Instead of relying on group.InterItemSpacing,
the fix computes half of the requested horizontal and vertical spacing
and applies that half-spacing through item.ContentInsets so each item
contributes to the gap. It then sets group.InterItemSpacing to 0, keeps
section.InterGroupSpacing for spacing between rows or columns, and adds
matching half-spacing to section.ContentInsets. This makes the first
row/column participate when spacing changes, which fixes the issue where
only later rows or columns visually updated.

**Tested the behavior in the following platforms: **

- [ ] Android
- [ ] Windows
- [x] iOS
- [x] Mac

### Reference:

N/A

### Issues Fixed:

Fixes  #34257      

### Screenshots
| Before  | After  |
|---------|--------|
| <Video
src="https://github.com/user-attachments/assets/578dda69-1d60-474c-a6d8-23b3f9d29a50"
Width="300" Height="600"> | <Video
src="https://github.com/user-attachments/assets/7f3826e6-5922-4b6f-a6b9-de581b7db6c3"
Width="300" Height="600"> |
kubaflo pushed a commit that referenced this pull request Jul 10, 2026
… row and column (#34598)

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

### Issue Details:

Horizontalspacing / Verticalspacing is not not applied to the first
column in GridItemLayout using CollectionView on iOS,Mac and Android
platform.
        
### Root Cause:

The grid spacing was not being distributed symmetrically across the
active layout implementations, so edge items did not fully participate
when spacing changed at runtime. On iOS and MacCatalyst, the active
Items2 compositional layout path handled spacing in a way that visually
created gaps but did not cause the first column and first row to update
consistently with the rest of the grid.

### Description of Change:

- On iOS/MacCatalyst, the fix in LayoutFactory2.cs keeps the existing
compositional grid item sizing (FractionalWidth(1f / span) for vertical
grids and FractionalHeight(1f / span) for horizontal grids), but changes
how spacing is applied. Instead of relying on group.InterItemSpacing,
the fix computes half of the requested horizontal and vertical spacing
and applies that half-spacing through item.ContentInsets so each item
contributes to the gap. It then sets group.InterItemSpacing to 0, keeps
section.InterGroupSpacing for spacing between rows or columns, and adds
matching half-spacing to section.ContentInsets. This makes the first
row/column participate when spacing changes, which fixes the issue where
only later rows or columns visually updated.

**Tested the behavior in the following platforms: **

- [ ] Android
- [ ] Windows
- [x] iOS
- [x] Mac

### Reference:

N/A

### Issues Fixed:

Fixes  #34257      

### Screenshots
| Before  | After  |
|---------|--------|
| <Video
src="https://github.com/user-attachments/assets/578dda69-1d60-474c-a6d8-23b3f9d29a50"
Width="300" Height="600"> | <Video
src="https://github.com/user-attachments/assets/7f3826e6-5922-4b6f-a6b9-de581b7db6c3"
Width="300" Height="600"> |
KarthikRajaKalaimani added a commit to KarthikRajaKalaimani/maui that referenced this pull request Jul 10, 2026
kubaflo pushed a commit that referenced this pull request Jul 13, 2026
…or horizontal Item Spacing and Vertical Item Spacing - horizontally updating the spacing only applies to the second column (#36508)

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

**Summary** 
Revert the changes in the PR #34598 
**Reason**
The HorizontalItemSpacing / VerticalItemSpacing on GridItemsLayout
should behave like ColumnSpacing / RowSpacing on a MAUI Grid — spacing
only between items, not on outer edges.
kubaflo pushed a commit that referenced this pull request Jul 15, 2026
… row and column (#34598)

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

### Issue Details:

Horizontalspacing / Verticalspacing is not not applied to the first
column in GridItemLayout using CollectionView on iOS,Mac and Android
platform.
        
### Root Cause:

The grid spacing was not being distributed symmetrically across the
active layout implementations, so edge items did not fully participate
when spacing changed at runtime. On iOS and MacCatalyst, the active
Items2 compositional layout path handled spacing in a way that visually
created gaps but did not cause the first column and first row to update
consistently with the rest of the grid.

### Description of Change:

- On iOS/MacCatalyst, the fix in LayoutFactory2.cs keeps the existing
compositional grid item sizing (FractionalWidth(1f / span) for vertical
grids and FractionalHeight(1f / span) for horizontal grids), but changes
how spacing is applied. Instead of relying on group.InterItemSpacing,
the fix computes half of the requested horizontal and vertical spacing
and applies that half-spacing through item.ContentInsets so each item
contributes to the gap. It then sets group.InterItemSpacing to 0, keeps
section.InterGroupSpacing for spacing between rows or columns, and adds
matching half-spacing to section.ContentInsets. This makes the first
row/column participate when spacing changes, which fixes the issue where
only later rows or columns visually updated.

**Tested the behavior in the following platforms: **

- [ ] Android
- [ ] Windows
- [x] iOS
- [x] Mac

### Reference:

N/A

### Issues Fixed:

Fixes  #34257      

### Screenshots
| Before  | After  |
|---------|--------|
| <Video
src="https://github.com/user-attachments/assets/578dda69-1d60-474c-a6d8-23b3f9d29a50"
Width="300" Height="600"> | <Video
src="https://github.com/user-attachments/assets/7f3826e6-5922-4b6f-a6b9-de581b7db6c3"
Width="300" Height="600"> |
kubaflo pushed a commit that referenced this pull request Jul 22, 2026
… row and column (#34598)

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

### Issue Details:

Horizontalspacing / Verticalspacing is not not applied to the first
column in GridItemLayout using CollectionView on iOS,Mac and Android
platform.
        
### Root Cause:

The grid spacing was not being distributed symmetrically across the
active layout implementations, so edge items did not fully participate
when spacing changed at runtime. On iOS and MacCatalyst, the active
Items2 compositional layout path handled spacing in a way that visually
created gaps but did not cause the first column and first row to update
consistently with the rest of the grid.

### Description of Change:

- On iOS/MacCatalyst, the fix in LayoutFactory2.cs keeps the existing
compositional grid item sizing (FractionalWidth(1f / span) for vertical
grids and FractionalHeight(1f / span) for horizontal grids), but changes
how spacing is applied. Instead of relying on group.InterItemSpacing,
the fix computes half of the requested horizontal and vertical spacing
and applies that half-spacing through item.ContentInsets so each item
contributes to the gap. It then sets group.InterItemSpacing to 0, keeps
section.InterGroupSpacing for spacing between rows or columns, and adds
matching half-spacing to section.ContentInsets. This makes the first
row/column participate when spacing changes, which fixes the issue where
only later rows or columns visually updated.

**Tested the behavior in the following platforms: **

- [ ] Android
- [ ] Windows
- [x] iOS
- [x] Mac

### Reference:

N/A

### Issues Fixed:

Fixes  #34257      

### Screenshots
| Before  | After  |
|---------|--------|
| <Video
src="https://github.com/user-attachments/assets/578dda69-1d60-474c-a6d8-23b3f9d29a50"
Width="300" Height="600"> | <Video
src="https://github.com/user-attachments/assets/7f3826e6-5922-4b6f-a6b9-de581b7db6c3"
Width="300" Height="600"> |
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 24, 2026
@github-actions github-actions Bot modified the milestones: .NET 10 SR9, .NET 10 SR10 Aug 20, 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 community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/ios platform/macos macOS / Mac Catalyst s/agent-fix-win AI found a better alternative fix than the PR 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.

[MAUI] I2_Vertical grid for horizontal Item Spacing and Vertical Item Spacing - horizontally updating the spacing only applies to the second column

6 participants