question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Ionic v4-beta.3] Bug navigation between tab page & no page tab - back button redirects to wrong tab

See original GitHub issue

Bug Report

Ionic Info

Ionic:

   ionic (Ionic CLI)          : 4.1.0 (/usr/local/lib/node_modules/ionic)
   Ionic Framework            : @ionic/angular 4.0.0-beta.3
   @angular-devkit/core       : 0.7.0-rc.3
   @angular-devkit/schematics : 0.7.0-rc.3
   @angular/cli               : 6.0.8
   @ionic/ng-toolkit          : 1.0.0
   @ionic/schematics-angular  : 1.0.1

Cordova:

   cordova (Cordova CLI) : 7.1.0
   Cordova Platforms     : ios 4.5.5
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.2, cordova-plugin-ionic-webview 2.0.2, (and 4 other plugins)

System:

   ios-deploy : 1.9.2
   ios-sim    : 6.1.1
   NodeJS     : v10.6.0 (/usr/local/bin/node)
   npm        : 6.4.0
   OS         : macOS High Sierra
   Xcode      : Xcode 9.4.1 Build version 9F2000

Describe the Bug I have an application with a tabs ( 5 pages home, search, map , info and tarif). From the search page i can go on a non-tab page like this this.router.navigate(['station'], { queryParams: station}); On the station page i have a back button to return to the search page <ion-back-button text=""></ion-back-button> The back button disappear at the second time. Here are some additional informations:

tabs.router.module.ts

const routes: Routes = [
  {
    path: 'tabs',
    component: TabsPage,
    children: [
      {
        path: 'home',
        outlet: 'home',
        component: HomePage
      },
      {
        path: 'search',
        outlet: 'search',
        component: SearchPage
      },
      {
        path: 'map',
        outlet: 'map',
        component: MapPage
      },
      {
        path: 'info',
        outlet: 'info',
        component: InfoPage
      },
      {
        path: 'tarif',
        outlet: 'tarif',
        component: TarifPage
      }
    ]
  },
  {
    path: '',
    redirectTo: '/tabs/(home:home)',
    pathMatch: 'full'
  }
];

app-routing.module.ts

const routes: Routes = [
  { path: '', loadChildren: './tabs/tabs.module#TabsPageModule' },
  { path: 'map', loadChildren: './map/map.module#MapPageModule' },
  { path: 'search', loadChildren: './search/search.module#SearchPageModule' },
  { path: 'station', loadChildren: './station/station.module#StationPageModule' },
  { path: 'info', loadChildren: './info/info.module#InfoPageModule' },
  { path: 'tarif', loadChildren: './tarif/tarif.module#TarifPageModule' }
];

i don’t know if it’s my bad or a bug ?

Steps to Reproduce Steps to reproduce the behavior:

  1. Click on tab menu to go to search page
  2. From search page go to station page ( a non-tab page)
  3. Go back to search page with back button
  4. Click on the same station to go on station page
  5. The back button disappear, i can’t go back on search page

Expected Behavior Fix nav when i from a non-tab page

Additional Context I have a log when i go to the station page at the second time ion-router-outlet.js:32 router-outlet destroyed

And i have an another issue, how i can conserve the tab menu on my station page ?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:20
  • Comments:58 (11 by maintainers)

github_iconTop GitHub Comments

11reactions
paulstelzercommented, Jan 15, 2019

Let’s make my summarize the issue:

  • You leave the tabs section on tab User with routerDirection="forward"
  • Now you want to go back
  • You will send back to tab 1 (Home) - not to User where you left the tabs

2019-01-15_10-55-14

  • The reason: The url is only tabs, not the last tab page you visited

chrome_2018-12-14_15-06-24

So this route is matching:

      {
        path: '',
        redirectTo: '/tabs/home',
        pathMatch: 'full',
      },

And the user will be redirect to home instead of tabs/user

This is based on https://github.com/lampi87/ionic-bug-test (you have to add the redirect route again to see the issue). This repo has not the redirect route, so the user stays on User where he left the tabs

6reactions
TioChachi29commented, Feb 28, 2019

In tabs.router.module.ts change this:

const routes: Routes = [ { path: 'tabs', component: TabsPage, children: [ ... { path: '', redirectTo: '/tabs/tab1', pathMatch: 'full' }

for this (remove /tab1):

{ path: '', redirectTo: '/tabs', pathMatch: 'full' }

This solves the back button of the topbar as the physical of android. It works well for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[IONIC V4] Back button + Tabs is always redirecting on the ...
When i am for exemple on the tab 4 and i go on a child page and then i press the back button...
Read more >
Ionic 4 ion-tabs navigation problem: When back button is ...
I press back button and it goes back to chat tab (should go back to home page instead). However, it works fine on...
Read more >
Framework7 Release Notes
Fixed issue with parsing route params for Master Detail master page when navigating directly to detail page. Tabs. Automatically set initial animated tab...
Read more >
How to Combine Ionic Side Menu and Tabs Navigation
This will be the case when we select our special page which has no tab bar, or when we navigate back from that...
Read more >
Using "replaceUrl" In Order To Honor The Back-Button While ...
Ben Nadel follows-up on his previous post regarding chained absolute and local redirects with the Router in Angular 7.2.13.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found