diff --git a/src/Controls/src/Core/NavigationPage/NavigationPage.cs b/src/Controls/src/Core/NavigationPage/NavigationPage.cs index e544f4d19958..5e0edc694d8b 100644 --- a/src/Controls/src/Core/NavigationPage/NavigationPage.cs +++ b/src/Controls/src/Core/NavigationPage/NavigationPage.cs @@ -585,7 +585,7 @@ void OnWindowChanged(object sender, EventArgs e) } var flyoutPage = _toolbar.FindParentOfType(); - if (flyoutPage != null && flyoutPage.Parent is IWindow && flyoutPage.Toolbar == _toolbar) + if (flyoutPage is not null && flyoutPage.Toolbar == _toolbar) { flyoutPage.Toolbar = null; } diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/TitleUpdatesAfterShowingNonFlyoutPage.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/TitleUpdatesAfterShowingNonFlyoutPage.png new file mode 100644 index 000000000000..f574ab35fd68 Binary files /dev/null and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/TitleUpdatesAfterShowingNonFlyoutPage.png differ diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue33615.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue33615.cs new file mode 100644 index 000000000000..f878420c0190 --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue33615.cs @@ -0,0 +1,81 @@ +namespace Maui.Controls.Sample.Issues; + +[Issue(IssueTracker.Github, 33615, "[Android] Title of FlyOutPage is not updating anymore after showing a NonFlyOutPage", PlatformAffected.Android)] +public class Issue33615 : TestFlyoutPage +{ + NavigationPage _navigationPage; + + protected override void Init() + { + Flyout = new ContentPage + { + Title = "Menu", + Content = new Label { Text = "Flyout Menu" } + }; + + var detailPage1 = new ContentPage { Title = "DetailPage1" }; + _navigationPage = new NavigationPage(detailPage1); + Detail = _navigationPage; + + detailPage1.Content = new VerticalStackLayout + { + VerticalOptions = LayoutOptions.Center, + Children = + { + new Button + { + Text = "Show NonFlyoutPage", + AutomationId = "ShowNonFlyoutButton", + Command = new Command(() => + { + this.Window.Page = new Issue33615NonFlyoutPage(this); + }) + }, + new Button + { + Text = "Navigate to DetailPage2", + AutomationId = "NavigateToDetailPage2Button", + Command = new Command(async () => + { + await _navigationPage.PushAsync(new ContentPage + { + Title = "DetailPage2", + Content = new Label + { + Text = "DetailPage2", + AutomationId = "DetailPage2Label" + } + }); + }) + }, + new Label + { + Text = "DetailPage1", + AutomationId = "DetailPage1Label" + } + } + }; + } +} + +class Issue33615NonFlyoutPage : ContentPage +{ + public Issue33615NonFlyoutPage(Page flyoutPage) + { + Title = "NonFlyoutPage"; + Content = new VerticalStackLayout + { + VerticalOptions = LayoutOptions.Center, + Children = + { + new Label { Text = "NonFlyoutPage" }, + new Button + { + Text = "Back to FlyoutPage", + AutomationId = "BackToFlyoutButton", + Command = new Command(() => this.Window.Page = flyoutPage) + } + } + }; + } +} diff --git a/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/TitleUpdatesAfterShowingNonFlyoutPage.png b/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/TitleUpdatesAfterShowingNonFlyoutPage.png new file mode 100644 index 000000000000..412b1d32ef8d Binary files /dev/null and b/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/TitleUpdatesAfterShowingNonFlyoutPage.png differ diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue33615.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue33615.cs new file mode 100644 index 000000000000..bd89032268ee --- /dev/null +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue33615.cs @@ -0,0 +1,42 @@ +using NUnit.Framework; +using UITest.Appium; +using UITest.Core; + +namespace Microsoft.Maui.TestCases.Tests.Issues; + +public class Issue33615 : _IssuesUITest +{ + public Issue33615(TestDevice device) : base(device) { } + + public override string Issue => "[Android] Title of FlyOutPage is not updating anymore after showing a NonFlyOutPage"; + + [Test] + [Category(UITestCategories.FlyoutPage)] + public void TitleUpdatesAfterShowingNonFlyoutPage() + { + // Wait for the FlyoutPage detail (DetailPage1) to load + App.WaitForElement("ShowNonFlyoutButton"); + + // Show a NonFlyoutPage by changing Window.Page + App.Tap("ShowNonFlyoutButton"); + + // Wait for the NonFlyoutPage to appear + App.WaitForElement("BackToFlyoutButton"); + + // Go back to the FlyoutPage + App.Tap("BackToFlyoutButton"); + + // Wait for the FlyoutPage to be restored with DetailPage1 + App.WaitForElement("NavigateToDetailPage2Button"); + + // Navigate to DetailPage2 — the toolbar title should update to "DetailPage2" + App.Tap("NavigateToDetailPage2Button"); + + // Verify DetailPage2 is the current page + App.WaitForElement("DetailPage2Label"); + + // The toolbar title must match "DetailPage2" — use VerifyScreenshot to + // detect if the toolbar is frozen on the old title "DetailPage1" + VerifyScreenshot(); + } +} diff --git a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/TitleUpdatesAfterShowingNonFlyoutPage.png b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/TitleUpdatesAfterShowingNonFlyoutPage.png new file mode 100644 index 000000000000..41cf00896def Binary files /dev/null and b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/TitleUpdatesAfterShowingNonFlyoutPage.png differ diff --git a/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios-26/TitleUpdatesAfterShowingNonFlyoutPage.png b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios-26/TitleUpdatesAfterShowingNonFlyoutPage.png new file mode 100644 index 000000000000..1465b436b84f Binary files /dev/null and b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios-26/TitleUpdatesAfterShowingNonFlyoutPage.png differ diff --git a/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/TitleUpdatesAfterShowingNonFlyoutPage.png b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/TitleUpdatesAfterShowingNonFlyoutPage.png new file mode 100644 index 000000000000..f7ee21cdcca8 Binary files /dev/null and b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/TitleUpdatesAfterShowingNonFlyoutPage.png differ