Ionic-framework: bug: Navigation and history

Created on 13 Jul 2015  路  10Comments  路  Source: ionic-team/ionic-framework

Type: bug

Platform: all

I've found a few questions on StackOverflow about navigation, history and how it should work.
Most people - and myself - struggle to understand how things are supposed to work.

There a codepen here where I am trying to figure why history doesn't always remember the last view rendered.

Using the sequence: Home - Fact1 - Fact2 - Fact3 - Fact2

you can see the back button shows Fact1. I would expect Fact3.

Going through the code base I kind of figured out why that happens. It seems that $ionicHistory keeps track of all the views storing them in a collection. If the element is already in the collection, it is fetched using the info attached to it.

The view Fact2 was previously rendered and it's back view was Fact1.

If you try another sequence, though: Home - Fact1 - Fact2 - Home

You notice that the back button now is Fact2. Home should be the root and it should not have any back button.
If I play the same sequence over and over: Home - Fact1 - Fact2 - Home - Fact1 - Fact2 - Home
etc etc I can see the collection views of $ionicHistory.viewHistory() grows indefinitely.

Most helpful comment

Hi,

This issue is not closed. I am still having this issue as of Ionic CLI 1.7.10.
This is a major issue for me, due to which i am not able to use caching at all & have to use ugly workarounds. Appreciate if this can be resolved.

All 10 comments

+1

+1

Greetings @Leftyx!

I've closed this issue because my sensors indicated it was old and inactive, and may have already been fixed in recent versions of Ionic. However, if you are still experiencing this issue, please feel free to reopen this issue by creating a new one, and include any examples and other necessary information, so that we can look into it further.

Thank you for allowing me to assist you.

Hi,

This issue is not closed. I am still having this issue as of Ionic CLI 1.7.10.
This is a major issue for me, due to which i am not able to use caching at all & have to use ugly workarounds. Appreciate if this can be resolved.

Badhir,

nobody seem to be interested in navigation issues. There's not much we can do.

I have a sort of similar problem.
I generate a random number and push to Fact2 params to make sure it make a new view, instead of reusing the previous one. The view is cached based on name+params.

This is a nagging problem if you have nested views in a tab view. Please fix or suggest a workaround

I am also having hard time with this one, and everyone on our team in fact. If the issue is simply caching, just add cache-view="false" to your ion-view.
However we did not find any way to force proper behavior of Back button? In some scenarios we want the user to go back to "beginning" if they click on Back button from within "wizard" like flow. So for example:
Tab.Home -> Tab.Page1 -> Tab.Page2
Now if they click "Back" on Page2, we want them to go to Tab.Home. Normally when already entering Page2 we know that back view needs changing, but is there a reliable way of changing back view?

Wierd, unable to get a way through this :
If we have a side menu, all the pages we visit clicking on menus from side menu are considered as root with the menu option appearing in each page (but going further with navigation in that branch it gets replaced by back arrow). The wit is, on pressing back from the page visited from the side menu say 'side page 1', it goes back to home page say 'Dashboard', but now it will have the back button in left corner in the header, instead of the menu icon, which appears as if the page where a home page.

Any idea how to go about this? :(

My solution/workaround:

Create an additional state to traverse to that references the same url, templateUrl, and controller.

For example if I have:

$stateProvider.state('fact2', { url: '/fact2/:factFilter', templateUrl: 'fact2.html', controller: 'Fact2Ctrl' })

Then I also create a "fact2" duplicate with only a different state name

$stateProvider.state('fact2_duplicate', { url: '/fact2/:factFilter', templateUrl: 'fact2.html', controller: 'Fact2Ctrl' })

If I am receiving the funny transition behavior, I can call $state.go('fact2_duplicate') the history will be more inline to what I am expecting.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

brandyscarney picture brandyscarney  路  3Comments

giammaleoni picture giammaleoni  路  3Comments

MrBokeh picture MrBokeh  路  3Comments

SebastianGiro picture SebastianGiro  路  3Comments

gio82 picture gio82  路  3Comments