diff --git a/src/Controls/src/Core/Compatibility/Handlers/FlyoutPage/iOS/PhoneFlyoutPageRenderer.cs b/src/Controls/src/Core/Compatibility/Handlers/FlyoutPage/iOS/PhoneFlyoutPageRenderer.cs index 67816eb67274..3a5dcbfebb7c 100644 --- a/src/Controls/src/Core/Compatibility/Handlers/FlyoutPage/iOS/PhoneFlyoutPageRenderer.cs +++ b/src/Controls/src/Core/Compatibility/Handlers/FlyoutPage/iOS/PhoneFlyoutPageRenderer.cs @@ -124,6 +124,11 @@ public override void ViewDidAppear(bool animated) { base.ViewDidAppear(animated); Page.SendAppearing(); + if (!_intialLayoutFinished) + { + _intialLayoutFinished = true; + SetInitialPresented(); + } } public override void ViewDidDisappear(bool animated) @@ -158,19 +163,6 @@ void SetInitialPresented() UpdateLeftBarButton(); } - public override void ViewWillLayoutSubviews() - { - // Orientation doesn't seem to be set to a stable correct value until here. - // So, we officially process orientation here. - if (!_intialLayoutFinished) - { - _intialLayoutFinished = true; - SetInitialPresented(); - } - - base.ViewWillLayoutSubviews(); - } - public override void ViewDidLoad() { base.ViewDidLoad(); diff --git a/src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt b/src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt index bbf0f6542ffd..3e07a450bda5 100644 --- a/src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt +++ b/src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt @@ -1,4 +1,5 @@ #nullable enable +*REMOVED*override Microsoft.Maui.Controls.Handlers.Compatibility.PhoneFlyoutPageRenderer.ViewWillLayoutSubviews() -> void ~Microsoft.Maui.Controls.Element.transientNamescope -> Microsoft.Maui.Controls.Internals.INameScope Microsoft.Maui.Controls.FlexLayout.CrossPlatformMeasure(double widthConstraint, double heightConstraint) -> Microsoft.Maui.Graphics.Size override Microsoft.Maui.Controls.ContentPresenter.OnSizeAllocated(double width, double height) -> void diff --git a/src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt b/src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt index bbf0f6542ffd..3e07a450bda5 100644 --- a/src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt +++ b/src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt @@ -1,4 +1,5 @@ #nullable enable +*REMOVED*override Microsoft.Maui.Controls.Handlers.Compatibility.PhoneFlyoutPageRenderer.ViewWillLayoutSubviews() -> void ~Microsoft.Maui.Controls.Element.transientNamescope -> Microsoft.Maui.Controls.Internals.INameScope Microsoft.Maui.Controls.FlexLayout.CrossPlatformMeasure(double widthConstraint, double heightConstraint) -> Microsoft.Maui.Graphics.Size override Microsoft.Maui.Controls.ContentPresenter.OnSizeAllocated(double width, double height) -> void diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue31372.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue31372.cs new file mode 100644 index 000000000000..200d0da29507 --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue31372.cs @@ -0,0 +1,59 @@ +namespace Maui.Controls.Sample.Issues; + +[Issue(IssueTracker.Github, 31372, "IsPresented=true Not Working on Initial Value in FlyoutPage", PlatformAffected.UWP | PlatformAffected.macOS)] + +public class Issue31372 : NavigationPage +{ + public Issue31372() + { + PushAsync(new Issue31372Page()); + } +} + +public class Issue31372Page : FlyoutPage +{ + public Issue31372Page() + { + + // Create Flyout Page + var flyoutPage = new ContentPage + { + Title = "Flyout", + Content = new StackLayout + { + Children = + { + new Label + { + Text = "This is Flyout", + AutomationId = "FlyoutLabel" + } + } + } + }; + + // Create Detail Page + var detailPage = new ContentPage + { + Title = "Detailpage", + Content = new StackLayout + { + Padding = 16, + Spacing = 16, + Children = + { + new Label + { + Text = "This is Detail Page which displays additional information." + }, + } + } + }; + + // Assign Flyout and Detail + Flyout = flyoutPage; + Detail = new NavigationPage(detailPage); + FlyoutLayoutBehavior = FlyoutLayoutBehavior.Popover; + IsPresented = true; + } +} \ No newline at end of file diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue31372.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue31372.cs new file mode 100644 index 000000000000..52b44efda6c0 --- /dev/null +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue31372.cs @@ -0,0 +1,22 @@ +using NUnit.Framework; +using UITest.Appium; +using UITest.Core; + +namespace Microsoft.Maui.TestCases.Tests.Issues +{ + public class Issue31372 : _IssuesUITest + { + public override string Issue => "IsPresented=true Not Working on Initial Value in FlyoutPage"; + + public Issue31372(TestDevice device) + : base(device) + { } + + [Test] + [Category(UITestCategories.FlyoutPage)] + public void VerifyIsPresentedInitialValue() + { + App.WaitForElement("FlyoutLabel"); + } + } +} \ No newline at end of file diff --git a/src/Core/src/Handlers/FlyoutView/FlyoutViewHandler.Windows.cs b/src/Core/src/Handlers/FlyoutView/FlyoutViewHandler.Windows.cs index 1165fd60c203..e72056f89365 100644 --- a/src/Core/src/Handlers/FlyoutView/FlyoutViewHandler.Windows.cs +++ b/src/Core/src/Handlers/FlyoutView/FlyoutViewHandler.Windows.cs @@ -21,12 +21,22 @@ protected override void ConnectHandler(RootNavigationView platformView) _navigationRootManager = MauiContext?.GetNavigationRootManager(); platformView.PaneOpened += OnPaneOpened; platformView.PaneClosed += OnPaneClosed; + platformView.Loaded += OnLoaded; + } + + void OnLoaded(object sender, RoutedEventArgs e) + { + if (VirtualView is not null) + { + PlatformView.IsPaneOpen = VirtualView.IsPresented; + } } protected override void DisconnectHandler(RootNavigationView platformView) { platformView.PaneOpened -= OnPaneOpened; platformView.PaneClosed -= OnPaneClosed; + platformView.Loaded -= OnLoaded; } void OnPaneOpened(NavigationView sender, object args)