Skip to content

Commit 082d25a

Browse files
[Windows, Catalyst] Fix IsPresented=true Not Working on Initial Value in FlyoutPage (#31515)
* mac fix added * Windows fix added * test case added * Update Issue31372.cs * Update Issue31372.cs * Update WindowHandler.iOS.cs * fix updated * Update WindowHandler.iOS.cs * Update WindowHandler.iOS.cs * Update PublicAPI.Shipped.txt * changes added in UnShipped file
1 parent 11ce8c9 commit 082d25a

File tree

6 files changed

+98
-13
lines changed

6 files changed

+98
-13
lines changed

src/Controls/src/Core/Compatibility/Handlers/FlyoutPage/iOS/PhoneFlyoutPageRenderer.cs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ public override void ViewDidAppear(bool animated)
124124
{
125125
base.ViewDidAppear(animated);
126126
Page.SendAppearing();
127+
if (!_intialLayoutFinished)
128+
{
129+
_intialLayoutFinished = true;
130+
SetInitialPresented();
131+
}
127132
}
128133

129134
public override void ViewDidDisappear(bool animated)
@@ -158,19 +163,6 @@ void SetInitialPresented()
158163
UpdateLeftBarButton();
159164
}
160165

161-
public override void ViewWillLayoutSubviews()
162-
{
163-
// Orientation doesn't seem to be set to a stable correct value until here.
164-
// So, we officially process orientation here.
165-
if (!_intialLayoutFinished)
166-
{
167-
_intialLayoutFinished = true;
168-
SetInitialPresented();
169-
}
170-
171-
base.ViewWillLayoutSubviews();
172-
}
173-
174166
public override void ViewDidLoad()
175167
{
176168
base.ViewDidLoad();

src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#nullable enable
2+
*REMOVED*override Microsoft.Maui.Controls.Handlers.Compatibility.PhoneFlyoutPageRenderer.ViewWillLayoutSubviews() -> void
23
~Microsoft.Maui.Controls.Element.transientNamescope -> Microsoft.Maui.Controls.Internals.INameScope
34
Microsoft.Maui.Controls.FlexLayout.CrossPlatformMeasure(double widthConstraint, double heightConstraint) -> Microsoft.Maui.Graphics.Size
45
override Microsoft.Maui.Controls.ContentPresenter.OnSizeAllocated(double width, double height) -> void

src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#nullable enable
2+
*REMOVED*override Microsoft.Maui.Controls.Handlers.Compatibility.PhoneFlyoutPageRenderer.ViewWillLayoutSubviews() -> void
23
~Microsoft.Maui.Controls.Element.transientNamescope -> Microsoft.Maui.Controls.Internals.INameScope
34
Microsoft.Maui.Controls.FlexLayout.CrossPlatformMeasure(double widthConstraint, double heightConstraint) -> Microsoft.Maui.Graphics.Size
45
override Microsoft.Maui.Controls.ContentPresenter.OnSizeAllocated(double width, double height) -> void
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
namespace Maui.Controls.Sample.Issues;
2+
3+
[Issue(IssueTracker.Github, 31372, "IsPresented=true Not Working on Initial Value in FlyoutPage", PlatformAffected.UWP | PlatformAffected.macOS)]
4+
5+
public class Issue31372 : NavigationPage
6+
{
7+
public Issue31372()
8+
{
9+
PushAsync(new Issue31372Page());
10+
}
11+
}
12+
13+
public class Issue31372Page : FlyoutPage
14+
{
15+
public Issue31372Page()
16+
{
17+
18+
// Create Flyout Page
19+
var flyoutPage = new ContentPage
20+
{
21+
Title = "Flyout",
22+
Content = new StackLayout
23+
{
24+
Children =
25+
{
26+
new Label
27+
{
28+
Text = "This is Flyout",
29+
AutomationId = "FlyoutLabel"
30+
}
31+
}
32+
}
33+
};
34+
35+
// Create Detail Page
36+
var detailPage = new ContentPage
37+
{
38+
Title = "Detailpage",
39+
Content = new StackLayout
40+
{
41+
Padding = 16,
42+
Spacing = 16,
43+
Children =
44+
{
45+
new Label
46+
{
47+
Text = "This is Detail Page which displays additional information."
48+
},
49+
}
50+
}
51+
};
52+
53+
// Assign Flyout and Detail
54+
Flyout = flyoutPage;
55+
Detail = new NavigationPage(detailPage);
56+
FlyoutLayoutBehavior = FlyoutLayoutBehavior.Popover;
57+
IsPresented = true;
58+
}
59+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using NUnit.Framework;
2+
using UITest.Appium;
3+
using UITest.Core;
4+
5+
namespace Microsoft.Maui.TestCases.Tests.Issues
6+
{
7+
public class Issue31372 : _IssuesUITest
8+
{
9+
public override string Issue => "IsPresented=true Not Working on Initial Value in FlyoutPage";
10+
11+
public Issue31372(TestDevice device)
12+
: base(device)
13+
{ }
14+
15+
[Test]
16+
[Category(UITestCategories.FlyoutPage)]
17+
public void VerifyIsPresentedInitialValue()
18+
{
19+
App.WaitForElement("FlyoutLabel");
20+
}
21+
}
22+
}

src/Core/src/Handlers/FlyoutView/FlyoutViewHandler.Windows.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,22 @@ protected override void ConnectHandler(RootNavigationView platformView)
2121
_navigationRootManager = MauiContext?.GetNavigationRootManager();
2222
platformView.PaneOpened += OnPaneOpened;
2323
platformView.PaneClosed += OnPaneClosed;
24+
platformView.Loaded += OnLoaded;
25+
}
26+
27+
void OnLoaded(object sender, RoutedEventArgs e)
28+
{
29+
if (VirtualView is not null)
30+
{
31+
PlatformView.IsPaneOpen = VirtualView.IsPresented;
32+
}
2433
}
2534

2635
protected override void DisconnectHandler(RootNavigationView platformView)
2736
{
2837
platformView.PaneOpened -= OnPaneOpened;
2938
platformView.PaneClosed -= OnPaneClosed;
39+
platformView.Loaded -= OnLoaded;
3040
}
3141

3242
void OnPaneOpened(NavigationView sender, object args)

0 commit comments

Comments
 (0)