Ionic-framework: bug: ionic vue not going back to correct tab after replacing route

Created on 12 Nov 2020  路  11Comments  路  Source: ionic-team/ionic-framework

Bug Report

Ionic version:


[ ] 4.x
[x] 5.x

Current behavior:

With a router containing a parent and child routes (tabs), start at a child route, navigating to a parent route, then back to a different child route, the child route loaded the second time around actually shows the first child component. The issue in the DOM shows as having a lower z-index and the 'ion-page-hidden' class on the second child route.

Example:

  • /parent-route
  • /tabs

    • /child-1


    • /child-2

Navigating from /tabs/child-1 to /parent-route back to /tabs/child-2 shows the child one component instead of the child two component (although the tabs component and URL do indeed show the child-2 route).

Expected behavior:
With the example above, the child-2 component should be shown when redirecting back down from the parent route.

Steps to reproduce:
Create a new ionic project for vue with 3 routes as explained in the example, using the tabs component. On load redirect to /tabs/child-1 and then use useRouter().replace('/parent-route') then useRouter().replace('/tabs/child-2').

Related code:
router/index.ts

const routes = {
  {
    path: '/',
    redirect: '/tabs/child-1'
  },
  {
    path: '/tabs',
    component: Tabs,
    children: [
      {
        path: 'child-1',
        component: () => import('@/views/ChildOne.vue')    
      },
      {
        path: 'child-2',
        component: () => import('@/views/ChildTwo.vue')
      }
    ]
  }
}

Unfortunately, my actual repo closed source so I can't disclose the actual code, however the router look near identical to the above. With the effect happening using the .replace('ROUTE') method. In reality the parent route is an sign-in (auth) route, and the children represent auth locked content. If a user logs out it moves them to the parent route and then when they log in it redirects them back to the child (tabs) route.

Other information:
In my actual app. Initial DOM on child-1: (1 parent route, 1 tabs route, 4 children routes)
Screenshot 2020-11-12 at 18 43 48

After redirecting to the parent page, and back to the other child page
Screenshot 2020-11-12 at 18 44 44

How the DOM should actually look if the bug wasn't present:
Screenshot 2020-11-12 at 20 11 33

What actually shows on screen (The initial child component with the correct tabs icon highlighted)
Screenshot 2020-11-12 at 18 44 52

What should actually show on screen (The redirected child component with the correct tabs icon highlighted)
Screenshot 2020-11-12 at 18 45 04

Ionic info:

Ionic:

   Ionic CLI       : 6.12.1 (/Users/devleaf_matt/.npm-global/lib/node_modules/@ionic/cli)
   Ionic Framework : @ionic/vue 5.4.3

Capacitor:

   Capacitor CLI   : 2.4.2
   @capacitor/core : 2.4.2

Utility:

   cordova-res : 0.15.2
   native-run  : 1.2.2

System:

   NodeJS : v12.18.1 (/usr/local/bin/node)
   npm    : 6.14.8
   OS     : macOS Big Sur
vue bug

Most helpful comment

Seems to be working as expected now on my actual app. Great job 馃憤

All 11 comments

Thanks for the issue. Can you please provide a full GitHub repo that I can use to reproduce the issue? The easiest way to do this would be to copy the minimal code required to an Ionic starter app.

Thanks for the issue! This issue has been labeled as needs reproduction. This label is added to issues that need a code reproduction.

Please provide a reproduction with the minimum amount of code required to reproduce the issue. Without a reliable code reproduction, it is unlikely we will be able to resolve the issue, leading to it being closed.

For a guide on how to create a good reproduction, see our Contributing Guide.

Hi Liam,

Thanks for your rapid response. Getting a github repo up now as we speak. Writing the readme and should be up in 5 and tagged on this issue.

Link here for github repo with instructions:
https://github.com/mattmilan-dev/Ionic-Vue-Routing-Bug

Thanks! I can reproduce the issue. I will work on a fix for this.

Awesome, look forward to the fix being in place. Apologies for not submitting a fix request myself. I've only got started with vue about a month ago so don't feel confident enough to know exactly what's going wrong. Thanks for your lightning-fast responses though 馃憤

I have the same problem

I have the same problem.I felt so confused for this

Can you try the following dev build and let me know if it resolves the issue?

npm install @ionic/[email protected] @ionic/[email protected]

Please note you will need an updated version of the vue-router pre-release: npm install vue-router@next

Seems to be working as expected now on my actual app. Great job 馃憤

Thanks for the issue. This has been resolved via https://github.com/ionic-team/ionic-framework/pull/22566, and a fix will be available in an upcoming release of Ionic Framework.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

giammaleoni picture giammaleoni  路  3Comments

SebastianGiro picture SebastianGiro  路  3Comments

fdnhkj picture fdnhkj  路  3Comments

vswarte picture vswarte  路  3Comments

manucorporat picture manucorporat  路  3Comments