Bug 31542 - Inconsistent behavior of Push/PopModalAsync (Android)
Summary: Inconsistent behavior of Push/PopModalAsync (Android)
Alias: None
Product: Forms
Classification: Xamarin
Component: Android (show other bugs)
Version: 1.4.2
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2015-07-01 12:02 UTC by Adam Kemp
Modified: 2017-12-20 00:17 UTC (History)
4 users (show)

See Also:
Tags: ac, android, navigation
Is this bug a regression?: ---
Last known good build:

Test case (1.13 MB, application/zip)
2015-07-01 12:02 UTC, Adam Kemp

Description Adam Kemp 2015-07-01 12:02:39 UTC
Created attachment 11805 [details]
Test case


Page1 pushes Page2 using Navigation.PushModalAsync (from Page1). Page2 then calls Navigation.PopModalAsync (from within Page2). That pop is using Page2's Navigation property, which should have its own modal stack. I believe this should throw, but instead it pops Page2. Next, Page2 pushes Page2 using Navigation.PushModalAsync (still from within Page2, using Page2's Navigation property). This page is never shown.

This behavior is inconsistent. There are two possibly consistent results:

1. Page2's call to PopModalAsync should throw.
2. Page3 should be shown.

The way it works now tries to sometimes pretend that there's only one stack, but other times acts as if each page has its own independent stack. I prefer option 1 because it forces people to understand the nested hierarchical nature of navigation, and it matches the behavior of iOS's native API, where each view controller can present one and only one thing at a time, and you can only dismiss it from the view controller that presented it.

To test this run the attached app (from this discussion: https://forums.xamarin.com/discussion/44635/why-does-popmodalasync-error-in-ios-but-work-on-android), press the button on the first page, and then the first button on the second page.
Comment 1 Jason Smith [MSFT] 2016-04-10 05:27:28 UTC
Modal stack is global, not per page.
Comment 2 Adam Kemp 2016-04-11 18:17:34 UTC
There's still a bug, though. If the modal stack is global then the correct behavior is option two listed above: Page3 should have been shown. Instead, Page3 was not shown because it was pushed from Page2's Navigation object while Page2 was not on screen. If the stack is global then why does it matter whether the Page you're pushing it from is on the stack or not?

This API is broken, and it's confusing people who try to use it.
Comment 3 Mike Norman 2017-06-19 15:42:40 UTC
Still repros.
Comment 4 David Ortinau [MSFT] 2017-12-20 00:17:54 UTC
Migrated to https://github.com/xamarin/Xamarin.Forms/issues/1427

Please subscribe to that issue for future updates.

Note You need to log in before you can comment on or make changes to this bug.