Repository navigation
Description
Feature Request
Ionic version:
[x] 5.x (Angular)
Describe the Feature Request
We have been migrating an application from Ionic 3 to Ionic 5, and we've found an issue navigating forward to a page that already exists within the current navigation stack.
For example, let's say I have page A and page B in my application, both of them with links that trigger forward navigation to one another. If I do the following navigation, everything looks right: Home -> A -> B -> A. However, when I press back, I'll be sent to Home, whereas I expected to be sent back to B. This happens because Ionic's StackController is reusing views, regardless of the type of navigation, and it's navigating backwards instead of forward (even though the forward animation is used).
This was not the case in Ionic 3, and even though routing has changed entirely under the hood with the new Angular router, this behaviour is specific to Ionic and there's nothing in Angular's router that prevents duplicated routes in the same navigation stack (in fact, the concept of a "navigation stack" is specific to Ionic).
This may not seem such a big problem for the example I used, but imagine that you are doing: Home -> A -> B -> C -> D -> A. At this point, the user lost all the B -> C -> D part of the navigation by navigating forward, which is not great user experience and may even result in losing data if there was a form in between.
Describe Preferred Solution
Support duplicated routes on a navigation stack, even if it requires some configuration and is not the default behaviour.
Describe Alternatives
One alternative we've been exploring is to declare the same route with different paths.
For example, I could declare the same route as /a, /deep/a, /deep/deep/a, etc. And every time I navigate forward on a given navigation stack, I add as many /deep to the path as instances of the page are already on the stack.
But this is not a great solution because it becomes cumbersome really quick, and this can potentially happen with any page so we'd be forced to declare /deep/deep/... for all the routes in our application which is not sustainable.
Related Code
-
Additional Context
-
Activity
liamdebeasi commentedon Jun 16, 2021
Thanks for the issue. I am going to close this as a duplicate of #19531.
ionitron-bot commentedon Jul 16, 2021
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.