fabulous-dev / Fabulous

Declarative UI framework for cross-platform mobile & desktop apps, using MVU and F# functional programming
https://fabulous.dev
Apache License 2.0
1.13k stars 122 forks source link

Make sure navigation events are not triggered by Fabulous #949

Closed TimLariviere closed 2 years ago

TimLariviere commented 2 years ago

Fixes #947

This PR does a couple things:

The main issue with #947 was all NavigationPage events were both triggered by user actions and programmatic changes made by Fabulous. There was no way to differentiate who was triggering the events to be able to react only to the user's actions.

To prevent this, I created CustomNavigationPage which has an internal counter for the number of times Fabulous pops pages. This counter is used to suppress the Popped events triggered programmatically by Fabulous. If the pop has been done by the user, then BackNavigated is triggered instead.

TimLariviere commented 2 years ago

I tried it against the repro branch and it was working perfectly well once I replaced onPopped with onBackNavigated

TimLariviere commented 2 years ago

I was wondering that too, but I want to believe that Xamarin.Forms triggers events sequentially 🙃