Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix navigation stuck on iOS when pushing on hidden tab section in TabBar #22574

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -621,15 +621,21 @@ void PushPage(Page page, bool animated, TaskCompletionSource<bool> completionSou
var renderer = (IPlatformViewHandler)page.ToHandler(_shellSection.FindMauiContext());

var tracker = _context.CreatePageRendererTracker();
tracker.ViewController = renderer.ViewController;
var pageViewController = renderer.ViewController!;
tracker.ViewController = pageViewController;
tracker.Page = page;

_trackers[page] = tracker;

if (completionSource != null)
_completionTasks[renderer.ViewController] = completionSource;
var parentTabBar = ParentViewController as UITabBarController;
var showsPresentation = parentTabBar == null || ReferenceEquals(parentTabBar.SelectedViewController, this);
if (completionSource != null && showsPresentation)
_completionTasks[pageViewController] = completionSource;

PushViewController(renderer.ViewController, animated);
PushViewController(pageViewController, animated);

if (completionSource != null && !showsPresentation)
completionSource.TrySetResult(true);
}

async void SendPoppedOnCompletion(Task popTask)
Expand Down
22 changes: 22 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue22570.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8" ?>
<Shell xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Maui.Controls.Sample.Issues.Issue22570">
<TabBar Route="main"
Title="Tabs">
<ShellContent
Title="Home"
Route="Home">
<ContentPage>
<VerticalStackLayout>
<Button Text="Navigate to a subpage"
AutomationId="button"
Clicked="Button_Clicked"/>
</VerticalStackLayout>
</ContentPage>
</ShellContent>
<ShellContent Title="Foo" Route="Foo">
<ContentPage/>
</ShellContent>
</TabBar>
</Shell>
36 changes: 36 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue22570.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.Xaml;

namespace Maui.Controls.Sample.Issues
{
[XamlCompilation(XamlCompilationOptions.Compile)]
[Issue(IssueTracker.Github, 22570, "[iOS] Cross TabBar navigation broken", PlatformAffected.iOS)]
public partial class Issue22570 : Shell
{
public Issue22570()
{
InitializeComponent();
Routing.RegisterRoute("Bar22570", typeof(Issue22570Page));
}

void Button_Clicked(object sender, System.EventArgs e)
{
_ = GoToAsync("//main/Foo/Bar22570");
}

public class Issue22570Page : ContentPage
{
public Issue22570Page()
{
Content = new VerticalStackLayout()
{
new Label()
{
Text = "Hello, World!",
AutomationId = "label"
}
};
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues
{
public class Issue22570 : _IssuesUITest
{
public Issue22570(TestDevice device)
: base(device)
{ }

public override string Issue => "[iOS] Cross TabBar navigation broken";

[Test]
[Category(UITestCategories.Shell)]
public void Issue22570Test()
{
App.WaitForElement("button");
App.Click("button");
App.WaitForElement("label");
}
}
}