From 1d4540eb7fe96ae6fac85986ade052fbe3cde3a5 Mon Sep 17 00:00:00 2001 From: HarishwaranVijayakumar Date: Mon, 18 May 2026 18:23:00 +0530 Subject: [PATCH 1/4] Add fix --- .../Shell/iOS/ShellPageRendererTracker.cs | 13 +++- .../TestCases.HostApp/Issues/Issue35471.cs | 67 +++++++++++++++++++ .../Tests/Issues/Issue35471.cs | 37 ++++++++++ 3 files changed, 115 insertions(+), 2 deletions(-) create mode 100644 src/Controls/tests/TestCases.HostApp/Issues/Issue35471.cs create mode 100644 src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue35471.cs diff --git a/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellPageRendererTracker.cs b/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellPageRendererTracker.cs index de76cd464460..6b21e427a21a 100644 --- a/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellPageRendererTracker.cs +++ b/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellPageRendererTracker.cs @@ -200,12 +200,21 @@ void OnToolbarPropertyChanged(object? sender, PropertyChangedEventArgs e) protected virtual void UpdateTitle() { - if (!ToolbarReady() || NavigationItem is null || _context?.Shell?.Toolbar is null) + + if (NavigationItem is null) { return; } - NavigationItem.Title = _context.Shell.Toolbar.Title; + if (ToolbarReady() && _context?.Shell?.Toolbar is not null) + { + NavigationItem.Title = _context.Shell.Toolbar.Title; + } + else if (Page?.IsSet(Page.TitleProperty) == true) + { + // Update back-stack pages so iOS back button/history menu reflects title changes + NavigationItem.Title = Page.Title; + } } diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue35471.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue35471.cs new file mode 100644 index 000000000000..75d49ad0b44a --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue35471.cs @@ -0,0 +1,67 @@ +namespace Maui.Controls.Sample.Issues; + +[Issue(IssueTracker.Github, 35471, "iOS Shell back button history menu does not update after runtime culture change", PlatformAffected.iOS | PlatformAffected.macOS)] +public class Issue35471 : TestShell +{ + ContentPage _rootPage; + + protected override void Init() + { + _rootPage = CreateContentPage("HomePage"); + _rootPage.Title = "Home"; + + var navigateButton = new Button + { + AutomationId = "NavigateToDetail", + Text = "Go to Detail Page", + Command = new Command(async () => + { + await Navigation.PushAsync(new Issue35471DetailPage(_rootPage)); + }) + }; + + _rootPage.Content = new VerticalStackLayout + { + Padding = 20, + Spacing = 10, + Children = + { + new Label { Text = "Root Page", AutomationId = "RootPageLabel" }, + navigateButton + } + }; + } + + class Issue35471DetailPage : ContentPage + { + readonly ContentPage _previousPage; + + public Issue35471DetailPage(ContentPage previousPage) + { + _previousPage = previousPage; + Title = "Detail"; + + var changeTitleButton = new Button + { + AutomationId = "ChangePreviousPageTitle", + Text = "Change Previous Page Title (simulate culture change)", + Command = new Command(() => + { + // Simulate runtime culture change by updating the previous page's title + _previousPage.Title = "Accueil"; + }) + }; + + Content = new VerticalStackLayout + { + Padding = 20, + Spacing = 10, + Children = + { + new Label { Text = "Detail Page", FontSize = 20 }, + changeTitleButton + } + }; + } + } +} diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue35471.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue35471.cs new file mode 100644 index 000000000000..7e977efa9981 --- /dev/null +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue35471.cs @@ -0,0 +1,37 @@ +#if IOS || MACCATALYST +using NUnit.Framework; +using UITest.Appium; +using UITest.Core; + +namespace Microsoft.Maui.TestCases.Tests.Issues +{ + public class Issue35471 : _IssuesUITest + { + public override string Issue => "iOS Shell back button history menu does not update after runtime culture change"; + + public Issue35471(TestDevice device) : base(device) + { + } + + [Test] + [Category(UITestCategories.Shell)] + public void ShellBackButtonHistoryUpdatesAfterTitleChange() + { + App.WaitForElement("NavigateToDetail"); + App.Tap("NavigateToDetail"); + + // Change the previous page's title (simulates runtime culture change) + App.WaitForElement("ChangePreviousPageTitle"); + App.Tap("ChangePreviousPageTitle"); + + // The back button should now show "Accueil" (updated title). + // Without the fix, it still shows "Home" (stale title). + App.WaitForElement("Accueil"); + App.Tap("Accueil"); + + // Verify we navigated back to root + App.WaitForElement("RootPageLabel"); + } + } +} +#endif From 1e277487a341adadd0feced18def075e15d16374 Mon Sep 17 00:00:00 2001 From: HarishwaranVijayakumar Date: Wed, 20 May 2026 16:47:36 +0530 Subject: [PATCH 2/4] Modify test --- .../TestCases.Shared.Tests/Tests/Issues/Issue35471.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue35471.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue35471.cs index 7e977efa9981..ace1424dfaac 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue35471.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue35471.cs @@ -26,8 +26,14 @@ public void ShellBackButtonHistoryUpdatesAfterTitleChange() // The back button should now show "Accueil" (updated title). // Without the fix, it still shows "Home" (stale title). - App.WaitForElement("Accueil"); - App.Tap("Accueil"); + if (App is AppiumIOSApp iosApp && HelperExtensions.IsIOS26OrHigher(iosApp)) + { + App.TapBackArrow(); // iOS 26+: no text on back button + } + else + { + App.TapBackArrow("Accueil"); + } // Verify we navigated back to root App.WaitForElement("RootPageLabel"); From dbff8f02d6387d648cc44d1bbbd2607ebb26355f Mon Sep 17 00:00:00 2001 From: HarishwaranVijayakumar Date: Thu, 21 May 2026 14:17:24 +0530 Subject: [PATCH 3/4] Update test --- .../Tests/Issues/Issue35471.cs | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue35471.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue35471.cs index ace1424dfaac..a02850495562 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue35471.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue35471.cs @@ -1,3 +1,5 @@ +// iOS/MacCatalyst only: The fix updates UINavigationItem.Title for back-stack pages, +// which iOS uses to display the back button text. This is an Apple platform-specific behavior. #if IOS || MACCATALYST using NUnit.Framework; using UITest.Appium; @@ -17,6 +19,14 @@ public Issue35471(TestDevice device) : base(device) [Category(UITestCategories.Shell)] public void ShellBackButtonHistoryUpdatesAfterTitleChange() { + // iOS 26+ no longer exposes the back button title text via accessibility, + // so there is no reliable way to assert the updated title in a UI test. + if (App is AppiumIOSApp iosApp && HelperExtensions.IsIOS26OrHigher(iosApp)) + { + Assert.Ignore("iOS 26+ does not expose back button title text via accessibility"); + } + + // Navigate to Detail page App.WaitForElement("NavigateToDetail"); App.Tap("NavigateToDetail"); @@ -24,18 +34,10 @@ public void ShellBackButtonHistoryUpdatesAfterTitleChange() App.WaitForElement("ChangePreviousPageTitle"); App.Tap("ChangePreviousPageTitle"); - // The back button should now show "Accueil" (updated title). - // Without the fix, it still shows "Home" (stale title). - if (App is AppiumIOSApp iosApp && HelperExtensions.IsIOS26OrHigher(iosApp)) - { - App.TapBackArrow(); // iOS 26+: no text on back button - } - else - { - App.TapBackArrow("Accueil"); - } - - // Verify we navigated back to root + // Verify back button now shows updated title "Accueil" + // Without the fix, UINavigationItem.Title is stale and still shows "Home" + App.WaitForElement("Accueil"); + App.Tap("Accueil"); App.WaitForElement("RootPageLabel"); } } From 0e97b65d65e4d0d94c820835bb4a3b649630aecc Mon Sep 17 00:00:00 2001 From: HarishwaranVijayakumar Date: Fri, 12 Jun 2026 17:00:16 +0530 Subject: [PATCH 4/4] Modify fix --- .../Handlers/Shell/iOS/ShellPageRendererTracker.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellPageRendererTracker.cs b/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellPageRendererTracker.cs index 6b21e427a21a..c24665ef3515 100644 --- a/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellPageRendererTracker.cs +++ b/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellPageRendererTracker.cs @@ -209,12 +209,11 @@ protected virtual void UpdateTitle() if (ToolbarReady() && _context?.Shell?.Toolbar is not null) { NavigationItem.Title = _context.Shell.Toolbar.Title; + return; } - else if (Page?.IsSet(Page.TitleProperty) == true) - { - // Update back-stack pages so iOS back button/history menu reflects title changes - NavigationItem.Title = Page.Title; - } + + // Update back-stack pages so iOS back button/history menu reflects title changes + NavigationItem.Title = Page?.Title; }