Bug 39104 - iOS Navigation.ModalStack not the same as Android and Windows
Summary: iOS Navigation.ModalStack not the same as Android and Windows
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.0.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Rui Marinho
URL:
Depends on:
Blocks:
 
Reported: 2016-02-24 20:54 UTC by Brian Lagunas
Modified: 2016-04-28 17:41 UTC (History)
6 users (show)

Tags: ac
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Brian Lagunas 2016-02-24 20:54:26 UTC
It seems that the iOS ModalStack does not include the initial MainPage.  This is causing a major issue because the MainPage is in the ModalStack on all other platforms except iOS.

The result of the sample app is as follows:

Android: 
   Modal Stack count = 3
   Pages on Modal Stack
      MainPage
      ViewA
      ViewB

Windows Phone:
   Modal Stack count = 3
   Pages on Modal Stack
      MainPage
      ViewA
      ViewB

iOS:
   Modal Stack count = 2
   Pages on Modal Stack
      ViewA
      ViewB

This will reproduce the issue:

    public class App : Application
    {
        public App()
        {
            // The root page of your application
            MainPage = new MainPage();
        }
    }

    class MainPage : ContentPage
    {
        public MainPage()
        {
            Title = "Main Page";

            var button = new Button() { Text = "Navigate to View A" };
            button.Clicked += (s, e) =>
            {
                Navigation.PushModalAsync(new ViewA());
            };

            Content = button;
        }
    }

    class ViewA : ContentPage
    {
        public ViewA()
        {
            Title = "View A";

            var button = new Button() { Text = "Navigate to View B" };
            button.Clicked += async (s, e) =>
            {
                await Navigation.PushModalAsync(new ViewB());
                Debug.WriteLine("View A Modal Stack Count = {0}", Navigation.ModalStack.Count);

                Debug.WriteLine("Pages on Modal Stack:");
                foreach (var view in Navigation.ModalStack)
                {
                    Debug.WriteLine(view.Title);
                }
            };

            Content = button;
        }
    }

    class ViewB : ContentPage
    {
        public ViewB()
        {
            Title = "View B";        
        }
    }
Comment 1 Jason Smith [MSFT] 2016-03-16 09:30:33 UTC
Should be fixed in 2.2.0-pre1
Comment 2 Parmendra Kumar 2016-04-25 17:08:57 UTC
I have checked this issue with 2.2.0-pre4 and observed that I am getting same result on  iOS and Android.

Hence closing this issue.

Thanks.
Comment 3 Brian Lagunas 2016-04-26 17:20:53 UTC
yes, the results are the same, but now the problem is that the MainPage is not in the navigation stack of any platform.

Given the above code snippet you would expect to see MainPage -> ViewA -> ViewB on the navigation stack.  The issue is that you only have ViewA -> ViewB.  MainPage is missing across the platforms.
Comment 4 Dbl 2016-04-27 18:00:20 UTC
Just citing google here: "A modal dialog is a window that forces the user to interact with it before they can go back to using the parent application. A great example of this would be a prompt for saving, or the "open file" dialog. They are often used when a user is forced to make an important decision."

To me it makes perfect sense that it's not in the modal stack at all now. One way or another it's at least consistent now :p
Comment 5 Rui Marinho 2016-04-28 17:41:20 UTC
We have clear this up with Bryan, so we are closing this one.