Skip to content
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

[Mac] TitleBar not always initally set #27487

Merged
merged 1 commit into from
Feb 4, 2025
Merged

Conversation

tj-devel709
Copy link
Member

Description of Change

When the TitleBar on MacCatalyst is set, on the initial page, it would not always display properly. The size and color would show up, but the page would not shift its content below the TitleBar and no elements would show inside the TitleBar. In a simple shell page, this behavior was not observed. However, it was observed inside a NavigationPage. In the NavigationPage example, if I pushed another ContentPage with the TitleBar set there, the titleBar would then display correctly.

The issue lied in the SetUpTitleBar method in the WindowViewController.cs file when comparing if (newTitleBar != iTitleBar). In the NavigationPage scenario, the initial window.TitleBar?.ToPlatform(mauiContext); was not null. Then when the MapTitleBar called SetUpTitleBar again, there would be a second comparison of two different types which would then null out our original TitleBar and remove the handler. When the handler was removed, everything would be reset leading to our elements in the titlebar not being displayed and the window content not shifting.

Issues Fixed

Fixes #27413

@PureWeen PureWeen added this to the .NET 9 SR4 milestone Jan 31, 2025
@PureWeen PureWeen added the p/0 Work that we can't release without label Jan 31, 2025
@tj-devel709 tj-devel709 marked this pull request as ready for review January 31, 2025 18:22
@Copilot Copilot bot review requested due to automatic review settings January 31, 2025 18:22
@tj-devel709 tj-devel709 requested a review from a team as a code owner January 31, 2025 18:22

Choose a reason for hiding this comment

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (4)

src/Core/src/Platform/iOS/WindowViewController.cs:111

  • [nitpick] The variable name 'newTitleBar' is ambiguous. It should be renamed to 'titleBar'.
var newTitleBar = window.TitleBar;

src/Core/src/Platform/iOS/WindowViewController.cs:112

  • [nitpick] The variable name 'newPlatTitleBar' is ambiguous. It should be renamed to 'platformTitleBar'.
var newPlatTitleBar = newTitleBar?.ToPlatform(mauiContext);

src/Core/src/Platform/iOS/WindowViewController.cs:110

  • Ensure that the behavior change is covered by tests in TestCases.HostApp and TestCases.Shared.Tests.
public void SetUpTitleBar(IWindow window, IMauiContext mauiContext)

src/Core/src/Platform/iOS/WindowViewController.cs:110

  • Verify that the public documentation reflects the behavior change if it affects the public API.
public void SetUpTitleBar(IWindow window, IMauiContext mauiContext)
@tj-devel709 tj-devel709 force-pushed the dev/TJ/TitleBarMac_Update1 branch from ebe9cd3 to 54b0921 Compare February 3, 2025 15:09
@PureWeen
Copy link
Member

PureWeen commented Feb 3, 2025

/rebase

@rmarinho rmarinho merged commit 30859b4 into main Feb 4, 2025
124 checks passed
@rmarinho rmarinho deleted the dev/TJ/TitleBarMac_Update1 branch February 4, 2025 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-titlebar p/0 Work that we can't release without platform/macOS 🍏 macOS / Mac Catalyst
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

MacCatalyst TitleBar not displaying properly
4 participants