Skip to content

feat: Allow duplicated routes on a navigation stack (Angular) #23455

Closed

Description

@NoelDeMartin

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

  1. liamdebeasi commented on Jun 16, 2021

    @liamdebeasi
    Contributor

    Thanks for the issue. I am going to close this as a duplicate of #19531.

  2. ionitron-bot commented on Jul 16, 2021

    @ionitron-bot

    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.

  3. locked and limited conversation to collaborators on Jul 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions