-
Notifications
You must be signed in to change notification settings - Fork 2k
[Mac] Fix Titlebar content is not aligned to left on fullscreen #30378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4f7296f
b38dd5c
0796d48
c49cf5a
baf4ec3
864f4d2
9fa0a2c
62511be
c9fde14
ff08443
4db7adb
b4c4f23
89dfab8
64a5fed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| namespace Maui.Controls.Sample.Issues; | ||
|
|
||
| [Issue(IssueTracker.Github, 30248, "TitleBar, MacCatalyst - content is not aligned to left on fullscreen", PlatformAffected.macOS)] | ||
|
|
||
| public class Issue30248 : ContentPage | ||
| { | ||
| public Issue30248() | ||
| { | ||
| Title = "Issue 30248"; | ||
|
|
||
| // 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 to the left in fullscreen mode", | ||
| AutomationId = "TitleBarAlignmentLabel", | ||
| FontSize = 32, | ||
| HorizontalOptions = LayoutOptions.Center | ||
| }, | ||
| new Button | ||
| { | ||
| Text = "Empty Button", | ||
| AutomationId = "EmptyButton", | ||
| HorizontalOptions = LayoutOptions.Center | ||
| } | ||
| } | ||
| }; | ||
| } | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| #if MACCATALYST //This is the Mac Specific issue, so restricting other platforms | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
|
|
||
| public class Issue30248 : _IssuesUITest | ||
| { | ||
| public override string Issue => "TitleBar, MacCatalyst - content is not aligned to left on fullscreen"; | ||
|
|
||
| public Issue30248(TestDevice device) | ||
| : base(device) | ||
| { } | ||
|
|
||
| [Test] | ||
| [Category(UITestCategories.Window)] | ||
| public void VerifyTitleBarContentinFullScreenmode() | ||
|
devanathan-vaithiyanathan marked this conversation as resolved.
|
||
| { | ||
| App.WaitForElement("TitleBarAlignmentLabel"); | ||
| try | ||
| { | ||
| App.EnterFullScreen(); | ||
| App.WaitForElement("TitleBarAlignmentLabel"); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [major] Regression Prevention and Test Coverage — This wait does not prove the app has entered fullscreen because |
||
| App.Tap("EmptyButton"); | ||
| VerifyScreenshot(includeTitleBar: true); | ||
| } | ||
| finally | ||
| { | ||
| App.ExitFullScreen(); | ||
| } | ||
| } | ||
|
devanathan-vaithiyanathan marked this conversation as resolved.
|
||
| } | ||
| #endif | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[moderate] Native Defaults Preservation -
ApplyMacCatalystMargin()now writes directly to the template rootGrid.Margin, including resetting it to zero in fullscreen. For a customTitleBar.ControlTemplatewhosePART_Rootis aGridwith its own margin, applying the template or resizing the window will overwrite the app's template-defined margin even though the template did not opt into the default TitleBar spacing behavior. Please preserve the existing template margin and apply/remove only the Mac traffic-light inset, or scope this mutation to the default template root.