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

#13527 - OnAppearing() is now called on every back navigation again b… #13528

Merged
merged 1 commit into from Feb 8, 2022

Conversation

gentledepp
Copy link
Contributor

…y not storing the previous page in a variable, but managing all previous pages in a Stack

Description of Change

Issues Resolved

API Changes

None

Platforms Affected

  • Core/XAML (all platforms)
  • iOS
  • Android
  • UWP

Behavioral/Visual Changes

None

Before/After Screenshots

Not applicable

Testing Procedure

PR Checklist

  • Targets the correct branch
  • Tests are passing (or failures are unrelated)

…again by not storing the previous page in a variable, but managing all previous pages in a Stack<Page>
@gentledepp
Copy link
Contributor Author

@jfversluis I just created the fix for the issue. Please comment

@@ -345,19 +345,23 @@ async void SetCurrent(Page newPage, bool popping = false, bool modal = false, Ac
Page previousPage = _currentPage;

if (modal && !popping && !newPage.BackgroundColor.IsDefault)
_modalBackgroundPage = previousPage;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of this line, when you navigate to the second modal level, _modalBackgroundPage already has a value and will be overwritten.
As of that, when you navigate back the second time, _modalBackgroundPage will already be null (this is done in the first pop of the navigation stack at line 360 below!). So you lost the outer modal page and cannot call its OnAppeare() callback anymore!

@jfversluis
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@jfversluis
Copy link
Member

Alright, this seems good to me. Sorry we left this around for so long! Congrats on becoming a Xamarin.Forms contributor @gentledepp and many thanks for your time and effort on this!

@jfversluis jfversluis merged commit 103ef3d into xamarin:5.0.0 Feb 8, 2022
@bitshftr
Copy link

Any chance this "fix" has now broken navigation when using Shell.Current.GoToAsync(...) ? Whenever I call Shell.Current.GoToAsync(...) now, I get the new window for a second, then navigation returns to the primary window without further interaction.

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

Successfully merging this pull request may close these issues.

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