Closed reigam closed 1 year ago
Thanks for the report @reigam
XF.NavigationPage has always been buggy with Fabulous when popping or pushing several pages at once. We really need to spend time to fix that.
In your example, the weird issue you're seeing is triggered by Helpers.reshuffle
.
This is because Xamarin.Forms will raise the BackNavigated
event, both if the user clicked the back button in the nav bar and if you popped a page programmatically.
The problem is that you already have updated the PageStash with the expected end state.
But because NavigationPopped
is triggered, Helpers.reshuffle will remove the last page (here "First Page") from the stack leaving it empty when it should not be possible.
Not sure why XF is not straight up throwing an exception here.
As a workaround while waiting for a proper fix, you could flag your PageStash as "ManuallyUpdated", so when NavigationPopped is called you can differentiate between the user clicking the back button of the NavigationPage or clicking the "Close all" button.
In the first case, you can pop a page from the PageStash. In the second case, you can keep the already updated stash.
Ok. I didn't consider, that the 'Close' Message also raises 'NavigationPopped'.
This works fine:
| NavigationPopped ->
if model.Global.PoppedByBackButton
then { model with Global = { PageStash = Helpers.reshuffle model.Global.PageStash
PoppedByBackButton = true }}, Cmd.none
else { model with Global = {model.Global with PoppedByBackButton = true}}, Cmd.none
| Close -> model, { globalModel with PoppedByBackButton = false
PageStash = [AppPages.names.FirstPage] }, Cmd.none
Thank you very much!
The following basic navigation setup works perfectly well for me on android, but shows some strange behavior on iOS: When I use 'Close' on the second page, everything works fine. However, if I use the same msg on the third page, the view changes to an empty page with the title of the first page, then immediately changes to the title of the third page, still with an empty view.
Shared.fs;
FirstPage.fs
SecondPage.fs
ThirdPage.fs
App.fs
full app can be viewed on: https://github.com/reigam/MultiNavPageStashTemplate (This is an older version, the behavior is the same with the newest version of fabulous and Xamarin).