Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
47 changes: 47 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue28440.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 28440, "FlyoutPage IsPresented not updated properly in windows", PlatformAffected.UWP)]
public class Issue28440 : FlyoutPage
{
public Issue28440()
{
FlyoutLayoutBehavior = FlyoutLayoutBehavior.Popover;

var flyoutMenuLabel = new Label
{
Text = "Flyout Menu",
AutomationId = "flyoutMenu"
};

var flyoutPage = new ContentPage
{
Title = "Menu",
Content = new StackLayout
{
Children = { flyoutMenuLabel }
}
};

var openMenuButton = new Button
{
Text = "Open Menu",
AutomationId = "Button"
};

openMenuButton.Clicked += (sender, args) => IsPresented = true;

var detailPage = new ContentPage
{
Content = new StackLayout
{
Children = { openMenuButton }
}
};

var navigationPage = new NavigationPage(detailPage);

Flyout = flyoutPage;
Detail = navigationPage;
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;
public class Issue28440 : _IssuesUITest
{
public override string Issue => "FlyoutPage IsPresented not updated properly in windows";

public Issue28440(TestDevice device)
: base(device)
{ }

[Test]
[Category(UITestCategories.FlyoutPage)]
public void CheckFlyoutPageIsPresentedState()
{
var buttonElement = App.WaitForElement("Button");
var buttonRect = buttonElement.GetRect();
App.Tap("Button");
App.WaitForElement("flyoutMenu");
float tapX = buttonRect.X + buttonRect.Width - 10;
float tapY = buttonRect.CenterY();
App.TapCoordinates(tapX, tapY);
App.WaitForElement("Button");
App.Tap("Button");
App.WaitForElement("flyoutMenu");
}
}
10 changes: 10 additions & 0 deletions src/Core/src/Handlers/FlyoutView/FlyoutViewHandler.Windows.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,28 @@ protected override void ConnectHandler(RootNavigationView platformView)
{
_navigationRootManager = MauiContext?.GetNavigationRootManager();
platformView.PaneOpened += OnPaneOpened;
platformView.PaneClosed += OnPaneClosed;
}

protected override void DisconnectHandler(RootNavigationView platformView)
{
platformView.PaneOpened -= OnPaneOpened;
platformView.PaneClosed -= OnPaneClosed;
}

void OnPaneOpened(NavigationView sender, object args)
{
VirtualView.IsPresented = sender.IsPaneOpen;
}

void OnPaneClosed(NavigationView sender, object args)
{
if (VirtualView is not null)
{
VirtualView.IsPresented = sender.IsPaneOpen;
}
}

static void UpdateDetail(IFlyoutViewHandler handler)
{
_ = handler.MauiContext ?? throw new InvalidOperationException($"{nameof(MauiContext)} should have been set by base class.");
Expand Down
Loading