Skip to content

Commit eb8f570

Browse files
Copilotmattleibowrmarinho
authored andcommitted
Fix CarouselView layout constraint issues on Mac Catalyst (#30714)
* Initial plan * Fix CarouselView layout constraint issues on Mac Catalyst Co-authored-by: mattleibow <[email protected]> * Add missing image --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: mattleibow <[email protected]> Co-authored-by: Rui Marinho <[email protected]>
1 parent dd4cb43 commit eb8f570

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

src/Controls/src/Core/Handlers/Items/CarouselViewHandler.iOS.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,22 @@ public static void MapLoop(CarouselViewHandler handler, CarouselView carouselVie
7171
(handler.Controller as CarouselViewController)?.UpdateLoop();
7272
}
7373

74-
public override Size GetDesiredSize(double widthConstraint, double heightConstraint) =>
75-
this.GetDesiredSizeFromHandler(widthConstraint, heightConstraint);
74+
public override Size GetDesiredSize(double widthConstraint, double heightConstraint)
75+
{
76+
var size = this.GetDesiredSizeFromHandler(widthConstraint, heightConstraint);
77+
78+
// Clamp size to constraints to prevent exceeding them on Mac Catalyst
79+
if (!double.IsInfinity(widthConstraint) && size.Width > widthConstraint)
80+
{
81+
size.Width = widthConstraint;
82+
}
83+
84+
if (!double.IsInfinity(heightConstraint) && size.Height > heightConstraint)
85+
{
86+
size.Height = heightConstraint;
87+
}
88+
89+
return size;
90+
}
7691
}
7792
}
14.6 KB
Loading

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue22417.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if TEST_FAILS_ON_WINDOWS && TEST_FAILS_ON_CATALYST //This test is failing, likely due to product issue, for more information: https://github.com/dotnet/maui/issues/27059
1+
#if TEST_FAILS_ON_WINDOWS //This test is failing, likely due to product issue, for more information: https://github.com/dotnet/maui/issues/27059
22
using NUnit.Framework;
33
using UITest.Appium;
44
using UITest.Core;

0 commit comments

Comments
 (0)