Skip to content
Closed
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 @@ -601,6 +601,19 @@ public override void PushViewController(UIViewController viewController, bool an
if (IsInMoreTab && ParentViewController is UITabBarController tabBarController)
{
tabBarController.MoreNavigationController.PushViewController(viewController, animated);

var tasks = _completionTasks;
var popTask = _popCompletionTask;

if (tasks.TryGetValue(viewController, out var source))
{
source.TrySetResult(true);
tasks.Remove(viewController);
}
else if (popTask != null)
{
popTask.TrySetResult(true);
}
}
else
{
Expand Down
74 changes: 74 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue27799.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
namespace Maui.Controls.Sample.Issues
{

[Issue(IssueTracker.Github, 27799, "[iOS] OnAppearing and OnNavigatedTo does not work when using extended Tabbar", PlatformAffected.iOS)]

public class Issue27799 : TestShell
{
private static int _onNavigatedToCount = 0;
private static int _onAppearingCount = 0;

protected override void Init()
{
Routing.RegisterRoute(nameof(Tab6Subpage), typeof(Tab6Subpage));
AddBottomTab("tab1");
AddBottomTab(new Tab2(), "tab2");
AddBottomTab("tab3");
AddBottomTab("tab4");
AddBottomTab("tab5");
AddBottomTab(new Tab6(), "Tab6");
}

class Tab2 : ContentPage
{
Label _onNavigatedToCountLabel;
Label _onAppearingCountLabel;
public Tab2()
{
_onNavigatedToCountLabel = new Label { AutomationId = "OnNavigatedToCountLabel", Text = $"OnNavigatedTo: {_onNavigatedToCount}" };
_onAppearingCountLabel = new Label { AutomationId = "OnAppearingCountLabel", Text = $"OnAppearing: {_onAppearingCount}" };
Content = new StackLayout
{
Children =
{
_onNavigatedToCountLabel,
_onAppearingCountLabel
}
};
}

protected override void OnNavigatedTo(NavigatedToEventArgs e)
{
_onNavigatedToCount++;
_onNavigatedToCountLabel.Text = $"OnNavigatedTo: {_onNavigatedToCount}";
}

protected override void OnAppearing()
{
_onAppearingCount++;
_onAppearingCountLabel.Text = $"OnAppearing: {_onAppearingCount}";
}
}

class Tab6 : ContentPage
{
public Tab6()
{
Content = new Button
{
Text = "Go to subpage6",
AutomationId = "GoToSubpage6Button",
Command = new Command(async () => await Current.GoToAsync(nameof(Tab6Subpage)))
};
}
protected override void OnNavigatedTo(NavigatedToEventArgs e) => _onNavigatedToCount++;
protected override void OnAppearing() => _onAppearingCount++;
}

class Tab6Subpage : ContentPage
{
protected override void OnNavigatedTo(NavigatedToEventArgs e) => _onNavigatedToCount++;
protected override void OnAppearing() => _onAppearingCount++;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#if IOS || ANDROID
using NUnit.Framework;
using NUnit.Framework.Legacy;
using UITest.Appium;
using UITest.Core;

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

public override string Issue => "[iOS] OnAppearing and OnNavigatedTo does not work when using extended Tabbar";

[Test]
[Category(UITestCategories.Shell)]
[Category(UITestCategories.Navigation)]
public void OnAppearingAndOnNavigatedToShouldBeCalles()
{
App.WaitForElement("More");
App.Click("More");
App.WaitForElement("Tab6");
App.Click("Tab6");
App.WaitForElement("GoToSubpage6Button");
App.Click("GoToSubpage6Button");
App.Click("tab2");
App.WaitForElement("OnNavigatedToCountLabel");
var onNavigatedToCountLabel = App.FindElement("OnNavigatedToCountLabel").GetText();
var onAppearingCountLabel = App.FindElement("OnAppearingCountLabel").GetText();

ClassicAssert.AreEqual("OnNavigatedTo: 3", onNavigatedToCountLabel);
ClassicAssert.AreEqual("OnAppearing: 3", onAppearingCountLabel);
}
}
}
#endif