Skip to content

Commit c03601d

Browse files
authored
Navigation from the 'more' tab (#26292)
* Navigation from the 'more' tab * Extended the uiTest * Update Issue18193.cs
1 parent cb16b8a commit c03601d

File tree

5 files changed

+140
-2
lines changed

5 files changed

+140
-2
lines changed

src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellItemRenderer.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ public override UIViewController SelectedViewController
7575
{
7676
ShellItem.SetValueFromRenderer(ShellItem.CurrentItemProperty, renderer.ShellSection);
7777
CurrentRenderer = renderer;
78-
MoreNavigationController?.PopToRootViewController(false);
7978
}
8079

8180
if (ReferenceEquals(value, MoreNavigationController))

src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellSectionRenderer.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,12 +588,24 @@ public override UIViewController[] PopToViewController(UIViewController viewCont
588588
public override void PushViewController(UIViewController viewController, bool animated)
589589
{
590590
_pendingViewControllers = null;
591-
base.PushViewController(viewController, animated);
591+
if (IsInMoreTab && ParentViewController is UITabBarController tabBarController)
592+
{
593+
tabBarController.MoreNavigationController.PushViewController(viewController, animated);
594+
}
595+
else
596+
{
597+
base.PushViewController(viewController, animated);
598+
}
592599
}
593600

594601
public override UIViewController PopViewController(bool animated)
595602
{
596603
_pendingViewControllers = null;
604+
if (IsInMoreTab && ParentViewController is UITabBarController tabBarController)
605+
{
606+
return tabBarController.MoreNavigationController.PopViewController(animated);
607+
}
608+
597609
return base.PopViewController(animated);
598610
}
599611

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
namespace Maui.Controls.Sample.Issues
2+
{
3+
[Issue(IssueTracker.Github, 18193, "[iOS] Navigation doesn't work on sixth tab in shell", PlatformAffected.iOS)]
4+
public class Issue18193 : Shell
5+
{
6+
public Issue18193()
7+
{
8+
var tabBar = new TabBar();
9+
10+
tabBar.Items.Add(CreateShellContent("MainPage", typeof(Issue18193MainPage), nameof(Issue18193MainPage)));
11+
tabBar.Items.Add(CreateShellContent("Page 2", typeof(Issue18193Page2), nameof(Issue18193Page2)));
12+
tabBar.Items.Add(CreateShellContent("Page 3", typeof(Issue18193Page3), nameof(Issue18193Page3)));
13+
tabBar.Items.Add(CreateShellContent("Page 4", typeof(Issue18193Page4), nameof(Issue18193Page4)));
14+
tabBar.Items.Add(CreateShellContent("Page 5", typeof(Issue18193Page5), nameof(Issue18193Page5)));
15+
tabBar.Items.Add(CreateShellContent("Page 6", typeof(Issue18193Page6), nameof(Issue18193Page6)));
16+
17+
Items.Add(tabBar);
18+
Routing.RegisterRoute(nameof(Issue18193DetailPage), typeof(Issue18193DetailPage));
19+
}
20+
21+
ShellContent CreateShellContent(string title, Type contentType, string route) => new()
22+
{
23+
Title = title,
24+
ContentTemplate = new DataTemplate(contentType),
25+
Route = route
26+
};
27+
}
28+
29+
class Issue18193MainPage : ContentPage
30+
{
31+
public Issue18193MainPage()
32+
{
33+
var button = new Button() { AutomationId = "NavigationToPage6Button", Text = "Navigate to page 6" };
34+
button.Clicked += (s, e) => Issue18193.Current.GoToAsync("//" + nameof(Issue18193Page6));
35+
Content = button;
36+
}
37+
}
38+
39+
class Issue18193DetailPage : ContentPage
40+
{
41+
public Issue18193DetailPage()
42+
{
43+
Title = "Detail Page";
44+
var button = new Button() { AutomationId = "NavigateBackButton", Text = "Navigate back" };
45+
button.Clicked += (s, e) => Issue18193.Current.GoToAsync("..");
46+
Content = button;
47+
}
48+
}
49+
50+
class Issue18193Page2 : ContentPage
51+
{
52+
public Issue18193Page2()
53+
{
54+
Content = new Button()
55+
{
56+
Text = "Navigate to page 5",
57+
Command = new Command(async () => await Issue18193.Current.GoToAsync("//" + nameof(Issue18193Page5))),
58+
AutomationId = "NavigateToPage5Button"
59+
};
60+
}
61+
}
62+
63+
public class Issue18193Page3 : ContentPage { }
64+
65+
public class Issue18193Page4 : ContentPage { }
66+
67+
public class Issue18193Page5 : ContentPage { }
68+
69+
public class Issue18193Page6 : ContentPage
70+
{
71+
public Issue18193Page6()
72+
{
73+
var button = new Button() { AutomationId = "NavigateToDetailButton", Text = "Navigate to detail page" };
74+
button.Clicked += (s, e) => Issue18193.Current.GoToAsync(nameof(Issue18193DetailPage));
75+
76+
var button2 = new Button() { AutomationId = "NavigateToPage2Button", Text = "Navigate to Page 2" };
77+
button2.Clicked += (s, e) => Issue18193.Current.GoToAsync("//" + nameof(Issue18193Page2));
78+
Content = new StackLayout
79+
{
80+
Children =
81+
{
82+
button,
83+
button2
84+
}
85+
};
86+
}
87+
}
88+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#if IOS
2+
using NUnit.Framework;
3+
using UITest.Appium;
4+
using UITest.Core;
5+
6+
namespace Microsoft.Maui.TestCases.Tests.Issues
7+
{
8+
public class Issue18193 : _IssuesUITest
9+
{
10+
public override string Issue => "[iOS] Navigation doesn't work on sixth tab in shell";
11+
12+
public Issue18193(TestDevice testDevice) : base(testDevice)
13+
{
14+
}
15+
16+
[Test]
17+
[Category(UITestCategories.Shell)]
18+
public void ShellNavigationShouldWorkInMoreTab()
19+
{
20+
App.WaitForElement("NavigationToPage6Button");
21+
App.Click("NavigationToPage6Button");
22+
App.WaitForElement("NavigateToDetailButton");
23+
App.Click("NavigateToDetailButton");
24+
App.WaitForElement("NavigateBackButton");
25+
App.Click("NavigateBackButton");
26+
App.WaitForElement("NavigateToPage2Button");
27+
App.Click("NavigateToPage2Button");
28+
App.WaitForElement("NavigateToPage5Button");
29+
App.Click("NavigateToPage5Button");
30+
App.WaitForElement("More");
31+
App.Click("More");
32+
}
33+
}
34+
}
35+
#endif

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue6784.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ public void OneMoreControllerOpensOnFirstClick()
3636
App.Tap("Tab 4");
3737
App.WaitForElement("More");
3838
App.Tap("More");
39+
// On iOS and Mac Catalyst, the first 'more' tab goes back to tab 11, the second click goes to the 'more' menu
40+
#if IOS || MACCATALYST
41+
App.Tap("More");
42+
#endif
3943
App.WaitForElement("Tab 12");
4044
App.Tap("Tab 12");
4145
}

0 commit comments

Comments
 (0)