Skip to content
This repository was archived by the owner on May 4, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion js/angular/service/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ function($rootScope, $state, $location, $window, $timeout, $ionicViewSwitcher, $
var viewIds = Object.keys(viewHistory.views);
viewIds.forEach(function(viewId) {
var view = viewHistory.views[viewId];
if ( view.backViewId === switchToView.viewId ) {
if ((view.backViewId === switchToView.viewId) && (view.historyId !== switchToView.historyId)) {
view.backViewId = null;
}
});
Expand Down
53 changes: 53 additions & 0 deletions test/unit/angular/service/history.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -1547,4 +1547,57 @@ describe('Ionic History', function() {

}));

it('should not remove backView references from Views in the same history stack', inject(function($state, $ionicHistory) {

var tab1Container = {};
var tab2Container = {};
ionicHistory.registerHistory(tab1Container);
ionicHistory.registerHistory(tab2Container);

// register tab1, view1
$state.go('tabs.tab1view1');
rootScope.$apply();
var tab1view1Reg = ionicHistory.register(tab1Container, false);

// register tab2, view1
$state.go('tabs.tab2view1');
rootScope.$apply();
var tab2view1Reg = ionicHistory.register(tab2Container, false);

// register tab2, view2
$state.go('tabs.tab2view2');
rootScope.$apply();
var tab2view2Reg = ionicHistory.register(tab2Container, false);
var tab2view2 = ionicHistory.getViewById(tab2view2Reg.viewId);
expect(tab2view2.backViewId).toEqual(tab2view1Reg.viewId);

// go back to tab2, view1
$state.go('tabs.tab2view1');
rootScope.$apply();
tab2view1Reg = ionicHistory.register(tab2Container, false);

// register tab1, view1
$state.go('tabs.tab1view1');
rootScope.$apply();
tab1view1Reg = ionicHistory.register(tab1Container, false);

// go to tab1, view 2
// register tab1, view2
$state.go('tabs.tab1view2');
rootScope.$apply();
var tab1view2Reg = ionicHistory.register(tab1Container, false);
currentView = ionicHistory.currentView();
expect(currentView.backViewId).toEqual(tab1view1Reg.viewId);

// register tab2, view1
$state.go('tabs.tab2view1');
rootScope.$apply();
tab2view1Reg = ionicHistory.register(tab2Container, false);
currentView = ionicHistory.currentView();
expect(currentView.backViewId).toEqual(tab1view2Reg.viewId);
expect(tab2view2.historyId).toEqual(currentView.historyId);
expect(tab2view2.backViewId).toEqual(currentView.viewId);

}));

});