Skip to content

Commit fcd590e

Browse files
[Windows] Flyout Menu Icon disappears from Window Title Bar after Navigation (#28240)
* Fixed drawer toggle button visiblity * Update ToolbarExtensions.cs * added test cases * added shell test cases * Update NavigationPageToolbar.cs
1 parent cd05e37 commit fcd590e

File tree

8 files changed

+156
-8
lines changed

8 files changed

+156
-8
lines changed

src/Controls/src/Core/NavigationPage/NavigationPageToolbar.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,11 @@ void UpdateBackButton()
180180

181181
// Set this before BackButtonVisible triggers an update to the handler
182182
// This way all useful information is present
183-
if (Parent is FlyoutPage flyout && flyout.ShouldShowToolbarButton() && !anyPagesPushed.Value)
183+
if (Parent is FlyoutPage flyout && flyout.ShouldShowToolbarButton()
184+
#if !WINDOWS // TODO NET 10 : Move this logic to ShouldShowToolbarButton
185+
&& !anyPagesPushed.Value
186+
#endif
187+
)
184188
_drawerToggleVisible = true;
185189
else
186190
_drawerToggleVisible = false;

src/Controls/src/Core/Platform/Windows/Extensions/ToolbarExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ public static void UpdateToolbarDynamicOverflowEnabled(this MauiToolbar platform
8787

8888
private static void UpdateBackButtonVisibility(MauiToolbar platformToolbar, Toolbar toolbar)
8989
{
90-
platformToolbar.IsBackButtonVisible =
91-
toolbar.BackButtonVisible
92-
? NavigationViewBackButtonVisible.Visible
90+
platformToolbar.IsBackButtonVisible =
91+
toolbar.BackButtonVisible
92+
? NavigationViewBackButtonVisible.Visible
9393
: NavigationViewBackButtonVisible.Collapsed;
9494
}
9595
}

src/Controls/src/Core/ShellToolbar.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,11 @@ internal void ApplyChanges()
9191
}
9292

9393
var flyoutBehavior = (_shell as IFlyoutView).FlyoutBehavior;
94+
#if WINDOWS
95+
_drawerToggleVisible = flyoutBehavior is FlyoutBehavior.Flyout;
96+
#else
9497
_drawerToggleVisible = stack.Count <= 1 && flyoutBehavior is FlyoutBehavior.Flyout;
98+
#endif
9599
BackButtonVisible = backButtonVisible && stack.Count > 1;
96100
BackButtonEnabled = _backButtonBehavior?.IsEnabled ?? true;
97101
ToolbarItems = _toolbarTracker.ToolbarItems;
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
namespace Maui.Controls.Sample.Issues
2+
{
3+
[Issue(IssueTracker.Github, 28130, "[Windows] Flyout Menu Icon disappears from Window Title Bar after Navigation", PlatformAffected.UWP)]
4+
public class Issue28130_Flyout : TestFlyoutPage
5+
{
6+
NavigationPage _navigationPage;
7+
string pageTitle = "Issue28130";
8+
protected override void Init()
9+
{
10+
Flyout = CreateFlyoutContent();
11+
FlyoutLayoutBehavior = FlyoutLayoutBehavior.Popover;
12+
Detail = _navigationPage = new NavigationPage(new Issue28130_DetailPage(pageTitle) { AutomationId = pageTitle});
13+
}
14+
15+
ContentPage CreateFlyoutContent()
16+
{
17+
var flyoutContent = new ContentPage() { Title = "Menu"};
18+
var layout = new VerticalStackLayout();
19+
var navigateButton = new Button() { Text = "Navigate to Page 2", AutomationId = "NavigateButton"};
20+
navigateButton.Clicked += (s, e) => _navigationPage.PushAsync(new Issue28130_Page1());
21+
layout.Add(navigateButton);
22+
flyoutContent.Content = layout;
23+
return flyoutContent;
24+
}
25+
}
26+
27+
public class Issue28130_Page1 : TestContentPage
28+
{
29+
protected override void Init()
30+
{
31+
Content = new VerticalStackLayout()
32+
{
33+
new Label()
34+
{
35+
Text = "Tap flyout",
36+
AutomationId="newPageLabel"
37+
}
38+
};
39+
}
40+
}
41+
42+
public class Issue28130_DetailPage : ContentPage
43+
{
44+
public Issue28130_DetailPage(string title)
45+
{
46+
Title = title;
47+
Content = new VerticalStackLayout()
48+
{
49+
new Label()
50+
{
51+
Text = "Once Loaded, Tap the flyout",
52+
AutomationId = "detailLabel"
53+
}
54+
};
55+
}
56+
}
57+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
namespace Maui.Controls.Sample.Issues
2+
{
3+
[Issue(IssueTracker.None,28130, "[Windows] Shell Flyout Menu Icon disappears from Window Title Bar after Navigation", PlatformAffected.UWP)]
4+
public class Issue28130_Shell : TestShell
5+
{
6+
7+
protected override void Init()
8+
{
9+
Routing.RegisterRoute(nameof(Issue28130_Page1), typeof(Issue28130_Page1));
10+
FlyoutBehavior = FlyoutBehavior.Flyout;
11+
FlyoutWidth = 300;
12+
ItemTemplate = new DataTemplate(() => CreateShellItemTemplate());
13+
ShellItem shellItem = new ShellItem() { Title = "Issue28130" };
14+
shellItem.Items.Add(new ShellContent() { Content = new Issue28130_DetailPage("Issue28130") });
15+
Items.Add(shellItem);
16+
}
17+
18+
Button CreateShellItemTemplate()
19+
{
20+
var navigateButton = new Button() { Text = "Navigate to Page 2" ,AutomationId = "NavigateButton"};
21+
navigateButton.Clicked += NavigateButton_Clicked;
22+
return navigateButton;
23+
}
24+
25+
private void NavigateButton_Clicked(object sender, EventArgs e)
26+
{
27+
GoToAsync(nameof(Issue28130_Page1));
28+
}
29+
}
30+
}

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue24547.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#if TEST_FAILS_ON_WINDOWS // Fix reverted. Refer For further info - https://github.com/dotnet/maui/issues/24547
2-
using NUnit.Framework;
1+
using NUnit.Framework;
32
using UITest.Appium;
43
using UITest.Core;
54

@@ -17,5 +16,4 @@ public void VerifyInitialToolbarButtonHidden()
1716
App.WaitForElement("DetailButton");
1817
VerifyScreenshot();
1918
}
20-
}
21-
#endif
19+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#if WINDOWS
2+
using NUnit.Framework;
3+
using UITest.Appium;
4+
using UITest.Core;
5+
6+
namespace Microsoft.Maui.TestCases.Tests.Issues
7+
{
8+
public class Issue28130_Flyout : _IssuesUITest
9+
{
10+
public Issue28130_Flyout(TestDevice testDevice) : base(testDevice)
11+
{
12+
}
13+
14+
public override string Issue => "[Windows] Flyout Menu Icon disappears from Window Title Bar after Navigation";
15+
16+
[Test]
17+
[Category(UITestCategories.FlyoutPage)]
18+
public void FlyoutMenuShouldNotDisappearAfterNavigation_FlyoutPage()
19+
{
20+
App.WaitForElement("detailLabel");
21+
App.TapInFlyoutPageFlyout("NavigateButton");
22+
App.WaitForElement("newPageLabel");
23+
App.TapFlyoutPageIcon();
24+
}
25+
}
26+
}
27+
#endif
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#if WINDOWS
2+
using NUnit.Framework;
3+
using UITest.Appium;
4+
using UITest.Core;
5+
6+
namespace Microsoft.Maui.TestCases.Tests.Issues
7+
{
8+
public class Issue28130_Shell : _IssuesUITest
9+
{
10+
public Issue28130_Shell(TestDevice testDevice) : base(testDevice)
11+
{
12+
}
13+
14+
public override string Issue => "[Windows] Shell Flyout Menu Icon disappears from Window Title Bar after Navigation";
15+
16+
[Test]
17+
[Category(UITestCategories.Shell)]
18+
public void FlyoutMenuShouldNotDisappearAfterNavigation_Shell()
19+
{
20+
App.WaitForElement("detailLabel");
21+
App.TapShellFlyoutIcon();
22+
App.Tap("Navigate to Page 2");
23+
App.WaitForElement("newPageLabel");
24+
App.TapShellFlyoutIcon();
25+
}
26+
}
27+
}
28+
#endif

0 commit comments

Comments
 (0)