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

[Windows] Fix FlyoutPage ShouldShowToolbarButton when overridden to return false, still shows button in title bar #25857

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
109 changes: 109 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue24547.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
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 Issue24547 : NavigationPage
{

public Issue24547() : base(new Issue24547PopoverPage())
{

}
public partial class Issue24547PopoverPage : FlyoutPage
Copy link
Contributor

Choose a reason for hiding this comment

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

D:\a\_work\1\s\src\Controls\tests\TestCases.HostApp\Issues\Issue24547.cs(4,15): error CS0260: Missing partial modifier on declaration of type 'Issue24547'; another partial declaration of this type exists [D:\a\_work\1\s\src\Controls\tests\TestCases.HostApp\Controls.TestCases.HostApp.csproj::TargetFramework=net9.0-windows10.0.20348.0]
D:\a\_work\1\s\src\Controls\tests\TestCases.HostApp\Issues\Issue24547.cs(4,15): error CS0260: Missing partial modifier on declaration of type 'Issue24547'; another partial declaration of this type exists [D:\a\_work\1\s\src\Controls\tests\TestCases.HostApp\Controls.TestCases.HostApp.csproj::TargetFramework=net9.0-windows10.0.19041.0]
    8570 Warning(s)
    2 Error(s)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have removed the partial keyword, could you please check once and let me know.

{
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"
};

button.Clicked += OnDetailButtonClicked;
return button;
}

private async void OnDetailButtonClicked(object sender, EventArgs e)
{
await this.Window.Page.Navigation.PushAsync(new NavigationPage(new Issue24547Page1()));
}

public override bool ShouldShowToolbarButton()
{
return false;
}
}

public partial class Issue24547Page1 : ContentPage
{
public Issue24547Page1()
{
Title = "Content Page";
VerticalStackLayout layout = new VerticalStackLayout
{
Children =
{
CreatePopButton()
}
};
Content = layout;

ToolbarItems.Add(new ToolbarItem
{
Text = "Item One",
});
}

private Button CreatePopButton()
{
Button button = new Button
{
Text = "Pop Button",
AutomationId = "PopButton",
};

button.Clicked += OnPopButtonClicked;
return button;
}

private async void OnPopButtonClicked(object sender, EventArgs e)
{
await this.Window.Page.Navigation.PopAsync();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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();
}

[Test]
[Category(UITestCategories.FlyoutPage)]
public void VerifyToolbarButtonHiddenOnNavigateBack()
{
App.WaitForElement("DetailButton");
App.Tap("DetailButton");
App.WaitForElement("PopButton");
App.Tap("PopButton");
App.WaitForElement("DetailButton");
VerifyScreenshot();
Copy link
Contributor

Choose a reason for hiding this comment

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

Triggered build. There are some pending snapshots.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We updated the test cases. Pending screenshots will be attached after the next CI trigger.

}
}
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.
Loading