ionic-team / ionic-team/ionic-framework

feat: ion-nav / ion-router: ability to swap current view

Open
#21,316 13 comments 4 reactions 0 assignees View on GitHub
package: core type: feature request
Dominant language
TypeScript
Stars
52.7k
Forks
13.3k
Avg merge
1d 15h
Merged PRs (30d)
51

Description

# Feature Request

**Ionic version:**
[x] **5.1.0**

**Describe the Feature Request**

Currently there is not a way to swap the current view in the navigation stack vs. pushing or popping.

For example, a simple contact management app might use a route '/contacts/:contactId'.

If the app provides a `Next` button then it is not clear how to show the next contact with the appropriate url while avoiding continuing to push new views onto the navigation stack.

Currently it keeps adding new views to the stack so the user experience would be:
- click on contact A
- click `next` to show contact B
- click `next` to show contact C
- now all the views are in the stack and the user needs to back through all of them

Swapping views in the stack is common for many mobile apps (email, contacts, etc.)

**Describe Preferred Solution**

One possible approach would be to add `swap` to the values for `RouterDirection`. This could then be passed to `ion-nav` so it could swap the view vs. pushing a new view onto the stack.

`ion-nav` could also be updated to expose a `swap` method.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.