ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

bug: $ionicHistory creates loop when linking to other tabs

Open ghost opened this issue 11 years ago • 9 comments

Type: bug

Platform: all

$ionicHistory creates a loop in the following situation:

tab 1 tab.list tab.map tab.location

tab 2 tab.activity

The idea is that I'd like to link from tab 2 to a tab1 state. Let's say I've made an href from the tab.activity view to the tab.location view. When I click that link it loads the view accordingly. Then I use the back button (currently triggers $ionicHistory.goBack()) it goes back to tab.activity. If I then navigate back to tab1 it shows the tab.location view I just linked to. Clicking the back button navigates to tab.activity view again. Thus creating a loop. To me it seems the $ionicHistory is hijacked by the other tab. Thus the tabs don't truly have isolated histories. Am I doing something wrong, because I'm lost for a fix. This seems to be a problem with how $ionicHistory works.

ghost avatar Jun 12 '15 20:06 ghost

I have this bug too. It is easy to reproduce.

Steps to reproduce:

  1. Prepare project 1.1. ionic start tabsApp 1.2. cd tabsApp 1.3. ionic platform add android 1.4. 1.5. ionic run android
  2. Navigation 2.1 tap on Account tab 2.2 tap on Chats tab 2.3 tap on first line (Ben Sparrow I guess) 2.4 tap on Account tab again

Then, tapping on back button creates a loop: Ben Sparrow -> Chats -> Account -> Ben Sparrow -> Chats -> Account -> and so on.

Bug reproduced on all android devices.

maxim-dev avatar Jun 23 '15 10:06 maxim-dev

+1

JerryBels avatar Aug 24 '15 14:08 JerryBels

I also was facing this issue. I commented this part of the code

// if switching to a different history, and the history of the view we're switching
// to has an existing back view from a different history than itself, then
// it's back view would be better represented using the current view as its back view
        tmp = getViewById(switchToView.backViewId);
        if (tmp && switchToView.historyId !== tmp.historyId) {
          hist.stack[hist.cursor].backViewId = currentView.viewId;
        }

This stops overwritting the backViewId of an existing view. Not perfect, but at least I am now able to exit the app with hard back button on Android.

didbarbosa avatar Oct 10 '15 21:10 didbarbosa

+1 Same here, I have something like this Home->Listing->Detail, if using $ionicHistory.goBack() it comes to a looping from Listing->Detail->Listing->Detail not ever coming to Home again. If using back button from browser works correctly.

wggley avatar Nov 20 '15 15:11 wggley

Hello! Are you all still experiencing this issue?

jgw96 avatar Mar 23 '16 19:03 jgw96

Hi. I can check this out later. I'm sorry I can't do this right now.

maxim-dev avatar Mar 23 '16 19:03 maxim-dev

@maxim-dev No problem at all!

jgw96 avatar Mar 23 '16 19:03 jgw96

@jgw96 the issue is still here. I had checked it with a new app. the bug is reproduced with steps as I mentioned above.

maxim-dev avatar Mar 24 '16 09:03 maxim-dev

Hi @maxim-dev, we have pushed this change to the master branch. It should be in the next nightly build. Please re-open if you continue to have issues. Thanks for using Ionic - we appreciate it!

Thanks, Dan

danbucholtz avatar Apr 04 '16 21:04 danbucholtz