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

iOS App Actions Navigation does not navigate to subpages correctly #16568

Open
edgiardina opened this issue Aug 6, 2023 · 4 comments · May be fixed by #22574
Open

iOS App Actions Navigation does not navigate to subpages correctly #16568

edgiardina opened this issue Aug 6, 2023 · 4 comments · May be fixed by #22574
Labels
area-controls-shell Shell Navigation, Routes, Tabs, Flyout area-navigation NavigationPage platform/iOS 🍎 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@edgiardina
Copy link

edgiardina commented Aug 6, 2023

Description

If you have a Tabbar as the primary shell control, and navigate using AppActions (or applinks, for that matter) with a subpage, the tabbar fails to switch to the selected tab.

Steps to Reproduce

  1. Create a new app with a Tabbar as the primary control
<?xml version="1.0" encoding="UTF-8" ?>
<Shell
    x:Class="MauiBug_iOS_AppAction_Navigation_Tabbar.AppShell"
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:local="clr-namespace:MauiBug_iOS_AppAction_Navigation_Tabbar"
    Shell.FlyoutBehavior="Disabled">

    <TabBar>
        <ShellContent
        Title="Page1"
        ContentTemplate="{DataTemplate local:MainPage}"
        Route="page1" />
        <ShellContent
        Title="Page2"
        ContentTemplate="{DataTemplate local:MainPage}"
        Route="page2" />
        <ShellContent
        Title="Page3"
        ContentTemplate="{DataTemplate local:MainPage}"
        Route="page3" />
        <ShellContent
        Title="Page4"
        ContentTemplate="{DataTemplate local:MainPage}"
        Route="page4" />
        <ShellContent
        Title="Page5"
        ContentTemplate="{DataTemplate local:MainPage}"
        Route="page5" />
    </TabBar>
</Shell>
  1. Create a subpage route meant to be visited below one of those tabpages
	public AppShell()
	{
		InitializeComponent();

        Routing.RegisterRoute("subpage", typeof(MainPage));
    }
  1. Create an app action to navigate to a path like //page1/subpage
         .ConfigureEssentials(essentials =>
            {
                //TODO: it's unclear whether icons must be in the Resources/Images folder or in the Platforms/{platform} folder
                essentials
                    .AddAppAction("page1", "Page 1") //works and changes selected tab
                    .AddAppAction("page2", "Page 2") //works and changes selected tab
                    .AddAppAction("page3/subpage", "Page3/subpage") //does not change active tab (but puts subpage in a nav stack underneath page3 tab)
                    .OnAppAction(App.HandleAppActions);

                essentials.UseVersionTracking();
            });
            
            
    public static void HandleAppActions(AppAction appAction)
    {
        App.Current.Dispatcher.Dispatch(async () =>
        {
            await Shell.Current.GoToAsync($"//{appAction.Id}");
        });
    }
  1. AppActions which only have a top level route like //page will work. AppActions with a subpage route will not change the current tab. Interestingly, if you manually navigate to the tab, you can see the subpage navigation was added, but the selected and visible tab from the tabbar is not shown.

Link to public reproduction project repository

https://github.com/edgiardina/MauiBug_iOS_AppAction_Navigation_Tabbar

Version with bug

7.0.86

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

iOS 16.4 but suspect all versions

Did you find any workaround?

No response

Relevant log output

No response

@edgiardina edgiardina added the t/bug Something isn't working label Aug 6, 2023
@jsuarezruiz jsuarezruiz added area-navigation NavigationPage platform/iOS 🍎 area-controls-shell Shell Navigation, Routes, Tabs, Flyout labels Aug 7, 2023
@jsuarezruiz jsuarezruiz added this to the Backlog milestone Aug 7, 2023
@ghost
Copy link

ghost commented Aug 7, 2023

We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.

@Zhanglirong-Winnie Zhanglirong-Winnie added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Feb 5, 2024
@Zhanglirong-Winnie
Copy link
Collaborator

Verified this issue with Visual Studio Enterprise 17.9.0 Preview 5. Can repro on iOS platform with sample project.
https://github.com/edgiardina/MauiBug_iOS_AppAction_Navigation_Tabbar
image

@blackforest-tom
Copy link

blackforest-tom commented Apr 18, 2024

I found out it has nothing to do with app actions (at least for me).
GoToAsync is bugged in iOS for navigating to another Tab's subpage - awaiting it hangs until you switch Tab manually.

Workaround (not sure why it even works, but I tried it out of desperation and it actually does... There has to be some important synchronous code executing within GoToAsync):

        var x = Shell.Current.GoToAsync("//main/tab3/subpage", navigationParameter);
#if IOS
        Shell.Current.CurrentItem.CurrentItem = Shell.Current.CurrentItem.Items[2];
#endif
        await x;

where main is the Route name of the TabBar.

If you change the active tab (setting CurrentItem) before calling GoToAsync, you first see //main/tab3 and from there subpage being pushed upon. If you do it like in the snippet above, it navigates to the subpage directly, without showing tab3 in between.

@albyrock87
Copy link
Contributor

albyrock87 commented May 22, 2024

Additional (simpler) information and a (simpler) how to reproduce repository:

Description

On iOS, using TabBar and navigating to a new Tab also pushing a page onto the navigation stack does not work:

  • No exception is thrown
  • Task is not completed
var shell = Shell.Current;
try
{
    // "main" is the `TabBar`
    // "Foo" is a different `ShellContent`
    // "Bar" is a page registered in the `Routing`
    await shell.GoToAsync("//main/Foo/Bar");
}
catch (Exception ex)
{ 
    // Add breakpoint here => not hit
    Console.WriteLine(ex.Message);
}
finally
{
    // Add breakpoint here => not hit
    Console.WriteLine("Finally");
}

Link to public reproduction project repository

https://github.com/albyrock87/maui-shell-issues/blob/main/MainPage.xaml.cs#L14-L28

Version with bug

8.0.40 SR5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-shell Shell Navigation, Routes, Tabs, Flyout area-navigation NavigationPage platform/iOS 🍎 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants