Shell backwards navigation problem by calling wrong OnAppearing/OnDisappearing #21274
Labels
area-controls-shell
Shell Navigation, Routes, Tabs, Flyout
area-core-lifecycle
XPlat and Native UIApplicationDelegate/Activity/Window lifecycle events
platform/android 🤖
platform/windows 🪟
s/triaged
Issue has been reviewed
s/verified
Verified / Reproducible Issue ready for Engineering Triage
t/bug
Something isn't working
Milestone
Description
I've found an issue where if you have stacked at least two pages by using Shell.GoToAsync, when you navigate back to the MainPage, it will trigger the OnAppearing of a previous page before the OnDisappearing of the current.
In the example code that is pointed out below, you will find a simple project where you have a MainPage and three other sub pages (Page1, Page2 and Page3).
So every time you navigate to a page, it will have a toolbar item to go to the next one until you reach the last one where you can only go backwards.
The problem is that when you reach the last page (Page3) and then press the back button of the Shell, it goes to Page2 and shows the right toolbar item to go to Page3. But if you press the back button again to go to Page1, you will see the Page1 but no ToolbarItem is beeing displayed (it should show the toolbar item to go to Page2). While debugging it, I figured out that when you press the back button it is triggering the following:
It should have triggers first the OnDisappearing of Page2 and then de OnAppearing of Page1 with the CurrentPage already set to the Page1.
Video:
https://github.com/dotnet/maui/assets/2288412/8f1e8506-e45e-463f-a964-c18ad6b06c35
Steps to Reproduce
Link to public reproduction project repository
https://github.com/nicop85/TestBackwardsNavigation.git
Version with bug
8.0.7 SR2
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
Android, Windows, I was not able test on other platforms
Affected platform versions
Windows 10.0.17763.0, Android 11 and up
Did you find any workaround?
No response
Relevant log output
No response
The text was updated successfully, but these errors were encountered: