Skip to content

Commit

Permalink
Fix dotnet#22570 & UI Test
Browse files Browse the repository at this point in the history
  • Loading branch information
kubaflo committed Jul 2, 2024
1 parent 76785b7 commit c8dac27
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Controls/src/Core/Shell/ShellNavigationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ internal async Task GoToAsync(
modalStackPreBuilt = true;

bool? isAnimated = (nextActiveSection != currentShellSection) ? false : animate;
await nextActiveSection.GoToAsync(navigationRequest, parameters, _shell.FindMauiContext()?.Services, isAnimated, isRelativePopping);

await _shell.Dispatcher.DispatchAsync(() =>
{
_ = nextActiveSection.GoToAsync(navigationRequest, parameters, _shell.FindMauiContext()?.Services, isAnimated, isRelativePopping);
});
}

if (shellItem != null)
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("Bar", typeof(Issue22570Page));
}

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

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 NUnit.Framework.Legacy;
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]
public void Issue22570Test()
{
App.WaitForElement("button");
App.Click("button");
App.WaitForElement("label");
}
}
}

0 comments on commit c8dac27

Please sign in to comment.