diff --git a/src/Controls/src/Core/TitleBar/TitleBar.cs b/src/Controls/src/Core/TitleBar/TitleBar.cs index 37eb60c04266..2e0d9d2987ce 100644 --- a/src/Controls/src/Core/TitleBar/TitleBar.cs +++ b/src/Controls/src/Core/TitleBar/TitleBar.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using Microsoft.Maui.Controls.Internals; using Microsoft.Maui.Graphics; @@ -348,7 +349,9 @@ static View BuildDefaultTemplate() var contentGrid = new Grid() { #if MACCATALYST - Margin = new Thickness(80, 0, 0, 0), + Margin = OperatingSystem.IsMacCatalystVersionAtLeast(26) + ? new Thickness(90, 0, 0, 0) + : new Thickness(80, 0, 0, 0), #endif HorizontalOptions = LayoutOptions.Fill, ColumnDefinitions = diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue33136.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue33136.cs new file mode 100644 index 000000000000..031543c925e8 --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue33136.cs @@ -0,0 +1,46 @@ +namespace Maui.Controls.Sample.Issues; + +[Issue(IssueTracker.Github, 33136, "TitleBar Content Overlapping with Traffic Light Buttons on Latest macOS Version", PlatformAffected.macOS)] +public class Issue33136 : ContentPage +{ + public Issue33136() + { + // Create TitleBar + var titleBar = new TitleBar + { + Title = "Maui App", + Subtitle = "Hello, World!", + ForegroundColor = Colors.Red, + HeightRequest = 48 + }; + + titleBar.LeadingContent = new Image { Source = "dotnet_bot.png", HeightRequest = 24 }; + + // Set the TitleBar on the current Window when this page appears + this.Loaded += (sender, e) => + { + if (Window != null) + { + Window.TitleBar = titleBar; + } + }; + + // Create the page content with a Label + Content = new VerticalStackLayout + { + Spacing = 25, + Padding = new Thickness(30), + VerticalOptions = LayoutOptions.Center, + Children = + { + new Label + { + Text = "TitleBar should be aligned properly", + AutomationId = "TitleBarAlignmentLabel", + FontSize = 32, + HorizontalOptions = LayoutOptions.Center + }, + } + }; + } +} diff --git a/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/VerifyTitleBarAlignment.png b/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/VerifyTitleBarAlignment.png new file mode 100644 index 000000000000..3fb91f7f0d40 Binary files /dev/null and b/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/VerifyTitleBarAlignment.png differ diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue33136.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue33136.cs new file mode 100644 index 000000000000..638176ca5ec5 --- /dev/null +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue33136.cs @@ -0,0 +1,22 @@ +#if TEST_FAILS_ON_ANDROID && TEST_FAILS_ON_IOS // TitleBar is only applicable for Windows and macOS +using NUnit.Framework; +using UITest.Appium; +using UITest.Core; + +namespace Microsoft.Maui.TestCases.Tests.Issues; + +public class Issue33136 : _IssuesUITest +{ + public Issue33136(TestDevice device) : base(device) { } + + public override string Issue => "TitleBar Content Overlapping with Traffic Light Buttons on Latest macOS Version"; + + [Test] + [Category(UITestCategories.Window)] + public void VerifyTitleBarAlignment() + { + App.WaitForElement("TitleBarAlignmentLabel"); + VerifyScreenshot(includeTitleBar: true); + } +} +#endif diff --git a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyTitleBarAlignment.png b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyTitleBarAlignment.png new file mode 100644 index 000000000000..b6c6bf3bcc93 Binary files /dev/null and b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyTitleBarAlignment.png differ