Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[iOS] Fix backwards navigation fails using Shell #14900

Merged
merged 1 commit into from
Nov 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
using System.Diagnostics;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;


#if UITEST
using Xamarin.UITest;
using NUnit.Framework;
using Xamarin.Forms.Core.UITests;
#endif

namespace Xamarin.Forms.Controls.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 14805, "[Bug] Xamarin.Forms.Shell v5.0.0.2196 Backwards Navigation not working in iOS 15.0",
PlatformAffected.iOS)]
#if UITEST
[NUnit.Framework.Category(Core.UITests.UITestCategories.Github5000)]
[NUnit.Framework.Category(UITestCategories.Shell)]
#endif
public class Issue14805 : TestShell
{
static int PushCount = 1;
static int PopCount = 1;

protected override void Init()
{
AddFlyoutItem(CreateContentPage(), "Push Me");
}

ContentPage CreateContentPage()
{
StackLayout layout = new StackLayout();

Label titleLabel = new Label()
{
Text = $"Page {PushCount - PopCount + 1}"
};

Button pushButton = new Button()
{
Text = "Push",
AutomationId = $"Push{PushCount}",
Command = new Command(async () =>
{
PushCount++;
Debug.WriteLine($"Push {PushCount}");
await Navigation.PushAsync(CreateContentPage());
})
};

Button popButton = new Button()
{
Text = "Pop",
AutomationId = $"Pop{PopCount}",
Command = new Command(async () =>
{
PopCount++;
Debug.WriteLine($"Pop {PopCount}");
await Navigation.PopAsync();
})
};

Label label = new Label()
{
Text = "Success",
AutomationId = "Success"
};

layout.Children.Add(titleLabel);
layout.Children.Add(pushButton);
layout.Children.Add(popButton);

if (PopCount == 3)
layout.Children.Add(label);

return new ContentPage()
{
Content = layout
};
}

#if UITEST
[Test]
public void PushingPagesAndThenPopNotWorking()
{
RunningApp.Tap("Push1");
RunningApp.Tap("Push2");
RunningApp.Tap("Pop1");
RunningApp.Tap("Push3");
RunningApp.Tap("Pop2");
RunningApp.Tap("Push4");
RunningApp.WaitForElement("Success");
}
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1824,6 +1824,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Issue14505-II.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue6387.xaml.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue14757.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue14805.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Bugzilla22229.xaml">
Expand Down
2 changes: 2 additions & 0 deletions Xamarin.Forms.Core/Shell/ShellSection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ async void IShellSectionController.SendPopping(Task poppingCompleted)
await poppingCompleted;

RemovePage(page);

(Parent?.Parent as IShellController)?.UpdateCurrentState(ShellNavigationSource.Pop);
}

async void IShellSectionController.SendPoppingToRoot(Task finishedPopping)
Expand Down