Skip to content

[Windows/Mac] Fix RTL FlowDirection causes overlap with native window control buttons in TitleBar #30400

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

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

devanathan-vaithiyanathan
Copy link
Contributor

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Issue Details

TitleBar doesn't properly handle right-to-left (RTL) layout direction, causing incorrect content alignment, overlapped with system buttons

Description of Change

Based on the FlowDirection, updated the TitleBar to apply appropriate Margin values to the content grid for both Windows and Mac platforms using visual states. This ensures correct alignment in both LTR and RTL layouts,

Issues Fixed

Fixes #30399

Tested the behavior in the following platforms.

  • Android
  • Windows
  • iOS
  • Mac
Before After
Mac
Before.mov
Mac
After.mov

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Jul 3, 2025
Copy link
Contributor

Hey there @@devanathan-vaithiyanathan! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@dotnet-policy-service dotnet-policy-service bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Jul 3, 2025
@devanathan-vaithiyanathan devanathan-vaithiyanathan marked this pull request as ready for review July 3, 2025 11:52
@Copilot Copilot AI review requested due to automatic review settings July 3, 2025 11:52
@devanathan-vaithiyanathan devanathan-vaithiyanathan requested a review from a team as a code owner July 3, 2025 11:52
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for right-to-left (RTL) layouts in the TitleBar on Windows and MacCatalyst by applying platform-specific margin adjustments via visual states, and includes a new UI test and host app page to verify the fix.

  • Introduces two new visual states (TitleBarLeftToRight / TitleBarRightToLeft) and applies them in the TitleBar template based on FlowDirection.
  • Updates TitleBar to update its visual state when FlowDirection changes and on template application.
  • Adds a host-page and shared UI test to toggle and verify RTL behavior.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/Controls/src/Core/TitleBar/TitleBar.cs Added LTR/RTL visual states, removed hardcoded margins, and hooked up FlowDirection changes to update the template.
src/Controls/tests/TestCases.HostApp/Issues/Issue30399.cs New ContentPage to host a toggle button for switching FlowDirection and test TitleBar behavior.
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30399.cs New UI test that taps the toggle button twice and captures a screenshot to verify correct RTL layout.
Comments suppressed due to low confidence (2)

src/Controls/tests/TestCases.HostApp/Issues/Issue30399.cs:1

  • Per UI testing guidelines, host app tests require a corresponding XAML page under TestCases.HostApp/Issues (Issue30399.xaml) with AutomationId attributes. A pure C# ContentPage may not be discovered properly by the test harness.
namespace Maui.Controls.Sample.Issues;

src/Controls/src/Core/TitleBar/TitleBar.cs:46

  • The new FlowDirection visual states and their margin behaviors should be reflected in the public XML documentation under /docs/ so consumers know about the LTR/RTL support.
		internal const string TitleBarLTRState = "TitleBarLeftToRight";

@@ -0,0 +1,26 @@
# if TEST_FAILS_ON_ANDROID && TEST_FAILS_ON_IOS // Titlebar applicable only on Windows and MacCatalyst
Copy link
Preview

Copilot AI Jul 3, 2025

Choose a reason for hiding this comment

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

The preprocessor conditional only compiles the test when both TEST_FAILS_ON_ANDROID and TEST_FAILS_ON_IOS are true, which prevents the test from running on Windows/MacCatalyst. You likely want to exclude Android OR iOS (e.g. #if !ANDROID && !IOS) so it runs where TitleBar is supported.

Suggested change
# if TEST_FAILS_ON_ANDROID && TEST_FAILS_ON_IOS // Titlebar applicable only on Windows and MacCatalyst
#if !TEST_FAILS_ON_ANDROID && !TEST_FAILS_ON_IOS // Titlebar applicable only on Windows and MacCatalyst

Copilot uses AI. Check for mistakes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Are not failing on that platforms, I would use something like:
#if MACCATALYST && WINDOWS

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jsuarezruiz , Based on your suggestion, I have modified the changes. Let me know if any changes needed

Property = MarginProperty,
TargetName = TemplateRootName,
#if MACCATALYST
Value = new Thickness(80, 0, 0, 0) // System buttons on left in macOS
Copy link
Contributor

Choose a reason for hiding this comment

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

Could extract magic numbers to Constants? Also, include a detailed comment explaining the values.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jsuarezruiz, I’ve extracted the numeric values into const variables and added appropriate comments.

@@ -0,0 +1,26 @@
# if TEST_FAILS_ON_ANDROID && TEST_FAILS_ON_IOS // Titlebar applicable only on Windows and MacCatalyst
Copy link
Contributor

Choose a reason for hiding this comment

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

Are not failing on that platforms, I would use something like:
#if MACCATALYST && WINDOWS

App.WaitForElement("ToggleFlowDirectionButton");
App.Tap("ToggleFlowDirectionButton");
App.Tap("ToggleFlowDirectionButton");
VerifyScreenshot(includeTitleBar: true);
Copy link
Contributor

Choose a reason for hiding this comment

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

Pending snapshots.

@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@jsuarezruiz
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/macos macOS / Mac Catalyst platform/windows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Windows, Mac] RTL FlowDirection causes overlap with native window control buttons in TitleBar
2 participants