Skip to content

Commit

Permalink
[Windows] Fix FlyoutPage ShouldShowToolbarButton when overridden to r…
Browse files Browse the repository at this point in the history
…eturn false, still shows button in title bar (#25857)

* Fixed-ToolBarVisible-Issue

* Added-Platform-Condition

* Removed

* Modified-TestCases-Added-SnapShot

* Added-Windows-SnapShot

---------

Co-authored-by: prakashKannanSf3972 <127308739+prakashKannanSf3972@users.noreply.github.com>
  • Loading branch information
1 parent 786b3aa commit 836975d
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 57 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue24547.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
Original file line number Diff line number Diff line change
@@ -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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 836975d

Please sign in to comment.