diff --git a/src/Controls/src/Core/Platform/Windows/Extensions/ToolbarExtensions.cs b/src/Controls/src/Core/Platform/Windows/Extensions/ToolbarExtensions.cs index 0fb31579521c..1a037424ca29 100644 --- a/src/Controls/src/Core/Platform/Windows/Extensions/ToolbarExtensions.cs +++ b/src/Controls/src/Core/Platform/Windows/Extensions/ToolbarExtensions.cs @@ -35,6 +35,10 @@ public static void UpdateBackButton(this MauiToolbar platformToolbar, Toolbar to platformToolbar.IsBackEnabled = toolbar.BackButtonEnabled && toolbar.BackButtonVisible; + // Adjusts WinUI TogglePaneButton visibility based on DrawerToggleVisible setting. + if (platformToolbar.TogglePaneButton is not null) + platformToolbar.TogglePaneButton.Visibility = toolbar.DrawerToggleVisible ? UI.Xaml.Visibility.Visible : UI.Xaml.Visibility.Collapsed; + platformToolbar .IsBackButtonVisible = (toolbar.BackButtonVisible) ? NavigationViewBackButtonVisible.Visible : NavigationViewBackButtonVisible.Collapsed; diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/VerifyInitialToolbarButtonHidden.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/VerifyInitialToolbarButtonHidden.png new file mode 100644 index 000000000000..db98dbb8d132 Binary files /dev/null and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/VerifyInitialToolbarButtonHidden.png differ diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue24547.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue24547.cs new file mode 100644 index 000000000000..73c372b067b3 --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue24547.cs @@ -0,0 +1,57 @@ +namespace Maui.Controls.Sample.Issues +{ + [Issue(IssueTracker.Github, 24547, "[Windows] FlyoutPage ShouldShowToolbarButton when overridden to return false, still shows button in title bar", PlatformAffected.UWP)] + public class Issue24547PopoverPage : FlyoutPage + { + public Issue24547PopoverPage() + { + FlyoutLayoutBehavior = FlyoutLayoutBehavior.Popover; + + Flyout = new ContentPage + { + Title = "Flyout", + BackgroundColor = Colors.Red, + Content = new StackLayout + { + Children = { + new Label { Text = "Flyout" } + } + } + }; + + ContentPage contentPage = new ContentPage + { + BackgroundColor = Colors.Green, + Title = "Detail", + Content = new StackLayout + { + Children = + { + CreateDetailButton() + } + } + }; + + Detail = new NavigationPage(contentPage); + Button button = new Button() { Text = "Menu", AutomationId = "MenuButton" }; + button.Clicked += (s, e) => IsPresented = true; + NavigationPage.SetTitleView(contentPage, button); + } + + private Button CreateDetailButton() + { + Button button = new Button + { + Text = "Detail", + AutomationId = "DetailButton" + }; + + return button; + } + + public override bool ShouldShowToolbarButton() + { + return false; + } + } +} \ No newline at end of file diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue24547.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue24547.cs new file mode 100644 index 000000000000..98aa1187a784 --- /dev/null +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue24547.cs @@ -0,0 +1,21 @@ +#if !MACCATALYST +using NUnit.Framework; +using UITest.Appium; +using UITest.Core; + +namespace Microsoft.Maui.TestCases.Tests.Issues; +public class Issue24547: _IssuesUITest +{ + public Issue24547(TestDevice device) : base(device) { } + + public override string Issue => "[Windows] FlyoutPage ShouldShowToolbarButton when overridden to return false, still shows button in title bar"; + + [Test] + [Category(UITestCategories.FlyoutPage)] + public void VerifyInitialToolbarButtonHidden() + { + App.WaitForElement("DetailButton"); + VerifyScreenshot(); + } +} +#endif \ No newline at end of file diff --git a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyInitialToolbarButtonHidden.png b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyInitialToolbarButtonHidden.png new file mode 100644 index 000000000000..50ea184c4a0b Binary files /dev/null and b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyInitialToolbarButtonHidden.png differ diff --git a/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/VerifyInitialToolbarButtonHidden.png b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/VerifyInitialToolbarButtonHidden.png new file mode 100644 index 000000000000..f240a5030146 Binary files /dev/null and b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/VerifyInitialToolbarButtonHidden.png differ