Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: angular, ion-back-button not going back to correct tab after leaving main tabs context #19801

Open
andreas-aeschlimann opened this issue Oct 30, 2019 · 3 comments
Labels
package: angular @ionic/angular package type: bug a confirmed bug report

Comments

@andreas-aeschlimann
Copy link

Bug Report

Ionic version:

[x] 4.x

Current behavior:

When you navigate from a tab page to another tab page and then go back with the ion-back-button, you will always end up at tab index 0 of the first tab page.

Expected behavior:

Instead, the app should go back to the tab where the user came from.

Steps to reproduce:

To illustrate the problem, I have taken the sample starter tab app of Ionic and extended it with a second tab page. This is the setup:

First tab page (TabsPage):

  • /tabs/tab1/
  • /tabs/tab2/
  • /tabs/tab3/

Second tab page (OtherTabsPage):

  • /other-tabs/other-tab1/

Reproduce the problem like this:

  • Open tab2
  • Click the button ("open nested tab") to go to the new tab page (other-tab1)
  • Now click the back button on the top left, you will end up on tab1 instead of tab2

Related code:

You can easily try it out here:

https://stackblitz.com/edit/ionic-v4-angular-tabs-hxxnpm

Ionic info:

Ionic:

   Ionic CLI                     : 5.4.4 (/usr/local/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.11.2
   @angular-devkit/build-angular : 0.803.15
   @angular-devkit/schematics    : 8.3.15
   @angular/cli                  : 8.3.15
   @ionic/angular-toolkit        : 2.1.1

Capacitor:

   Capacitor CLI   : 1.3.0
   @capacitor/core : 1.3.0

Cordova:

   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : none
   Cordova Plugins   : no whitelisted plugins (0 plugins total)

Utility:

   cordova-res : not installed
   native-run  : 0.2.8 (update available: 0.2.9)

System:

   ios-deploy : 1.9.2
   ios-sim    : 8.0.1
   NodeJS     : v10.16.0 (/usr/local/bin/node)
   npm        : 6.12.1
   OS         : macOS Mojave
   Xcode      : Xcode 11.0 Build version 11A420a

@ionitron-bot ionitron-bot bot added the triage label Oct 30, 2019
@liamdebeasi liamdebeasi added package: angular @ionic/angular package type: bug a confirmed bug report labels Oct 31, 2019
@ionitron-bot ionitron-bot bot removed the triage label Oct 31, 2019
@indraraj26
Copy link

Bump any news on this?

@liamdebeasi liamdebeasi changed the title bug: ion-back-button does not work properly on nested tabs bug: angular, ion-back-button not going back to correct tab after leaving main tabs context Apr 21, 2021
@Zapominacz
Copy link

I wonder if deep view checking will help with this issue:
In the StackController class, we are determining the back url in the pop method by:

const view = views[views.length - deep - 1];
let url = view.url; 
const viewSavedData = view.savedData;

I tried to replace the code above with:

let view = views[views.length - deep - 1];
let viewSavedData = view.savedData;
while (viewSavedData.get('primary')) {
  view = viewSavedData.get('primary').outlet.stackCtrl.activeView;
  viewSavedData = view.savedData;
}
let url = view.url;

And it properly fixed the issue in #23218

Do I miss something here?

@Zapominacz
Copy link

Ok, nevermind. Version 5.6.6 fixes that issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: angular @ionic/angular package type: bug a confirmed bug report
Projects
None yet
Development

No branches or pull requests

4 participants