From 6ca24b0bb412b4240bed49065fef3b064b1c3cf9 Mon Sep 17 00:00:00 2001 From: praveenkumarkarunanithi Date: Tue, 13 Jan 2026 18:13:16 +0530 Subject: [PATCH 1/3] Update MauiView.cs --- src/Core/src/Platform/iOS/MauiView.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Core/src/Platform/iOS/MauiView.cs b/src/Core/src/Platform/iOS/MauiView.cs index 2e47eb0da8a2..9529fcd4a934 100644 --- a/src/Core/src/Platform/iOS/MauiView.cs +++ b/src/Core/src/Platform/iOS/MauiView.cs @@ -357,13 +357,12 @@ SafeAreaPadding GetAdjustedSafeAreaInsets() return new SafeAreaPadding(left, right, top, bottom); } - // Fallback to legacy behavior - if (View is ISafeAreaView sav && sav.IgnoreSafeArea) - { - return SafeAreaPadding.Empty; - } + // Fallback to legacy ISafeAreaView behavior + if (View is ISafeAreaView sav) + return sav.IgnoreSafeArea ? SafeAreaPadding.Empty : baseSafeArea; - return baseSafeArea; + // Non-safe-area views pass through to parent + return SafeAreaPadding.Empty; } /// From 08ae0bf19aa1bcb986bc2287102bb585c8123029 Mon Sep 17 00:00:00 2001 From: praveenkumarkarunanithi Date: Wed, 14 Jan 2026 12:36:05 +0530 Subject: [PATCH 2/3] Update MauiView.cs --- src/Core/src/Platform/iOS/MauiView.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Core/src/Platform/iOS/MauiView.cs b/src/Core/src/Platform/iOS/MauiView.cs index 9529fcd4a934..06df6c168c19 100644 --- a/src/Core/src/Platform/iOS/MauiView.cs +++ b/src/Core/src/Platform/iOS/MauiView.cs @@ -359,7 +359,9 @@ SafeAreaPadding GetAdjustedSafeAreaInsets() // Fallback to legacy ISafeAreaView behavior if (View is ISafeAreaView sav) + { return sav.IgnoreSafeArea ? SafeAreaPadding.Empty : baseSafeArea; + } // Non-safe-area views pass through to parent return SafeAreaPadding.Empty; From 9689aa38be01014f4cabb50135d7d1f884a50eeb Mon Sep 17 00:00:00 2001 From: praveenkumarkarunanithi Date: Wed, 14 Jan 2026 15:40:59 +0530 Subject: [PATCH 3/3] test case update --- .../TestCases.HostApp/Issues/Issue33458.cs | 42 +++++++++++++++++++ .../Tests/Issues/Issue33458.cs | 29 +++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 src/Controls/tests/TestCases.HostApp/Issues/Issue33458.cs create mode 100644 src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue33458.cs diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue33458.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue33458.cs new file mode 100644 index 000000000000..167d03bef7ca --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue33458.cs @@ -0,0 +1,42 @@ +namespace Maui.Controls.Sample.Issues; + +[Issue(IssueTracker.Github, 33458, "SafeArea incorrectly applied when using ControlTemplate with ContentPresenter", PlatformAffected.iOS)] +public class Issue33458 : TestContentPage +{ + protected override void Init() + { + AutomationId = "TestPage"; + SafeAreaEdges = SafeAreaEdges.None; + ControlTemplate = new ControlTemplate(() => new ContentPresenter()); + + var stackLayout = new VerticalStackLayout + { + AutomationId = "TestStackLayout", + Padding = new Thickness(30, 0), + Spacing = 25, + BackgroundColor = Colors.Green, + SafeAreaEdges = SafeAreaEdges.None, + Children = + { + new Image + { + AutomationId = "BotImage", + Source = "dotnet_bot.png", + HeightRequest = 185, + Aspect = Aspect.AspectFit + }, + new Label { AutomationId = "HelloLabel", Text = "Hello, World!" }, + new Label { AutomationId = "WelcomeLabel", Text = "Welcome to\n.NET Multi-platform App UI" }, + new Button { AutomationId = "CounterBtn", Text = "Click me", HorizontalOptions = LayoutOptions.Fill } + } + }; + + Content = new ScrollView + { + AutomationId = "TestScrollView", + BackgroundColor = Colors.Red, + SafeAreaEdges = SafeAreaEdges.None, + Content = stackLayout + }; + } +} diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue33458.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue33458.cs new file mode 100644 index 000000000000..a4222946cae9 --- /dev/null +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue33458.cs @@ -0,0 +1,29 @@ +#if IOS || ANDROID +using NUnit.Framework; +using UITest.Appium; +using UITest.Core; + +namespace Microsoft.Maui.TestCases.Tests.Issues; + +public class Issue33458 : _IssuesUITest +{ + public override string Issue => "SafeArea incorrectly applied when using ControlTemplate with ContentPresenter"; + + public Issue33458(TestDevice device) : base(device) { } + + [Test] + [Category(UITestCategories.SafeAreaEdges)] + public void ScrollViewSafeAreaWorksWithControlTemplate() + { + var pageRect = App.WaitForElement("TestPage").GetRect(); + var scrollViewRect = App.WaitForElement("TestScrollView").GetRect(); + + // ContentPresenter should not apply safe area - ScrollView should match page bounds + Assert.That(scrollViewRect.Y, Is.EqualTo(pageRect.Y), + "ScrollView Y should match Page Y - no top inset from ContentPresenter"); + + Assert.That(scrollViewRect.Height, Is.EqualTo(pageRect.Height), + $"ScrollView height should match Page height - no insets from ContentPresenter. Expected: {pageRect.Height}, Actual: {scrollViewRect.Height}"); + } +} +#endif