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

Modal navigation back not working #48

Open
sthewissen opened this issue Jan 26, 2022 · 9 comments
Open

Modal navigation back not working #48

sthewissen opened this issue Jan 26, 2022 · 9 comments

Comments

@sthewissen
Copy link

sthewissen commented Jan 26, 2022

Using 3.0.1, I have the following navigation pattern:

  • My root is a TabbedPage, within the first tab sits a NavigationPage with a Page.
  • From that Page I open a new Modal which is also a NavigationPage with Page.
  • Pushing a new Page from that modally displayed Page and subsequently calling Back does nothing.

As far as I can tell, the system crashes on this line:

var prevPage = Application.Current.MainPage.Navigation.NavigationStack[0];

With a:

Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

Because we're in a Modal popup with its own NavigationStack I would expect the first thing Back does to be to pop the newly pushed page on the Modal navigation stack. If there is nothing left to go Back to on that stack, I assume the result should be to pop the entire modal.

Changing that specific line to the following at the very least fixes the back navigation in my specific case, but I don't quite oversee the consequences this has for the rest yet. Hoping you have a bit more insight into that :)

var prevPage = Application.Current.MainPage.Navigation.ModalStack[0];
@dhindrik
Copy link
Collaborator

Have you tried the latest preview? There was a fix in a PR about modals. If that does not fix the problem I can investigate it further.

Thank you for creating the issue.

@sthewissen
Copy link
Author

sthewissen commented Jan 26, 2022

Still occurring on 4.0.1-pre4. If you want to check out a sample;

https://github.com/sthewissen/MVP/tree/updating-the-lot

Go to create a contribution and pick a contribution type from the list. It should pop the page back after picking.

@dhindrik
Copy link
Collaborator

dhindrik commented Feb 1, 2022

It feels like something has changed with navigation in Xamarin.Forms since I wrote that code because it behaves very strangely. But I will investigate more how to fix it.

@BoobalanK
Copy link

Hey @dhindrik , I was having a problem in BackAsync. The ReturningParameter is null.

After i debugged the Sample Shell app from Samples Folder. I can see the 0 index in the NavigationStack is null. This is the reason the ReturningParameter never gets it value.

Hope this shed some light

@dhindrik
Copy link
Collaborator

@BoobalanK are you using Shell or not?

@BoobalanK
Copy link

Yes @dhindrik Using Shell. i tested the shell sample only from this location https://github.com/TinyStuff/TinyMvvm/tree/4.0.1-pre4/src/Samples

@dhindrik
Copy link
Collaborator

Are you using ShellViewBase?

@BoobalanK
Copy link

Yes @dhindrik

@vendhanparthy
Copy link

Hi @dhindrik, do you have any update for the ReturningParameter is null in BackAsync.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants