Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug] When navigating back to a previous page (modal stack), OnAppearing() is not called #13527

Closed
gentledepp opened this issue Jan 25, 2021 · 4 comments · Fixed by #13528
Closed

Comments

@gentledepp
Copy link
Contributor

gentledepp commented Jan 25, 2021

Description

When you have multiple pages in a modal stack and you navigate back, the OnAppearing() callback of the previous page that you return to will only be called for the most inner level.
E.g.: You have 3 modal pages: 1, 2 and 3. You start with page 1, then you navigate to 2 and from 2 to 3 (modally) => your stack will be 1/2/3;
Now, navigating back from 3 to 2 will call 2.OnAppearing(), but navigating back from 2 to 1 will not call 1.OnAppearing() wich breaks a lot of things!

This is because when you navigate to the next modal leve, UAP Platform.cs line 348 overwrites any _modalBackgroundPage even if there is already one!

Steps to Reproduce

  1. Create a sample that has a navigation page, pushes a nother navigation page as modal and then a 2nd one
  2. Navigating back one step to the 1st modal navigation page still triggers its "OnAppearing" callback
  3. However, navigating back to the root does not trigger "OnAppearing" anymore

Expected Behavior

Whenever you navigate back to the previous page, its "OnAppearing" callback should be called

Actual Behavior

It works if you only have one level of nesting. However, as soon as you have 2 modal pages, the outer ones "OnAppearing" is not called anymore

Basic Information

  • Version with issue: 4.8.x and 5.0.0

  • Last known good version: Anyhing before commit d103974 which broke everything (issue that was resoled: Modal Page with transparent background #8551)

  • Platform Target Frameworks:

    • UWP: any version. This is a bug in UAP Platform.cs
  • Android Support Library / AndroidX Version:

  • Affected Devices: all UWP devices

@jfversluis this issue occurs because of your fix for tranparent background of modals

@gentledepp gentledepp added s/unverified New report that has yet to be verified t/bug 🐛 labels Jan 25, 2021
gentledepp added a commit to Opti-Q/Xamarin.Forms that referenced this issue Jan 25, 2021
…again by not storing the previous page in a variable, but managing all previous pages in a Stack<Page>
gentledepp added a commit to Opti-Q/Xamarin.Forms that referenced this issue Jan 25, 2021
…again by not storing the previous page in a variable, but managing all previous pages in a Stack<Page>
@gentledepp gentledepp changed the title [Bug] OnAppearing on 1st level NavigationPage not called with nested modal navigation pages [Bug] When navigating back to a previous page (modal stack), OnAppearing() is not called Jan 25, 2021
gentledepp added a commit to Opti-Q/Xamarin.Forms that referenced this issue Jan 25, 2021
…again by not storing the previous page in a variable, but managing all previous pages in a Stack<Page>
@rmarinho rmarinho added a/page p/UWP e/3 🕒 3 and removed s/unverified New report that has yet to be verified labels Jan 26, 2021
@EmilAlipiev
Copy link
Contributor

thanks for reporting this. i have just came to create this issue.

bruzkovsky pushed a commit to Opti-Q/Xamarin.Forms that referenced this issue May 28, 2021
…again by not storing the previous page in a variable, but managing all previous pages in a Stack<Page>
@chadzhao

This comment was marked as off-topic.

@jfversluis

This comment was marked as off-topic.

@jfversluis
Copy link
Member

Oh even better, it seems a PR is already opened for this by @gentledepp thank you so much for that! Will check that out shortly and see if I can merge it.

jfversluis pushed a commit that referenced this issue Feb 8, 2022
…y not storing the previous page in a variable, but managing all previous pages in a Stack<Page> (#13528)
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants