Skip to content

bug: Vue routing in tabs mode cause re-render #18292

@xar

Description

@xar

Bug Report

Ionic version:
[x] 4.4

Current behavior:
Simple tabs structure in vue project with ionic vue router. When I switch tab previous component is removed from DOM and after that It needs to be fully re-rendered when I go back to that tab. It's reproducible also on ionic-vue-conference app. But working correctly on ionic-conference-app.

Expected behavior:
Component doesn't get removed but will be hidden.

Steps to reproduce:
Ionic conference app bug

Related code:

<ion-tabs>
    <ion-tab tab="dashboard">
        <!--                <DashboardIndex />-->
        <ion-vue-router name="dashboard" />
    </ion-tab>
    <ion-tab tab="benefits" :routes="['page2']">
        <ion-vue-router name="page2" />
    </ion-tab>
    <ion-tab tab="results" :routes="['page3']">
        <ion-vue-router name="page3" />
    </ion-tab>
    <ion-tab tab="profile" :routes="['page4']">
        <ion-vue-router name="page4" />
    </ion-tab>
    <template slot="bottom">
        <ion-tab-bar :key="1">
            <ion-tab-button v-for="tab in tabs" :key="tab.routeName" :tab="tab.routeName">
                <ion-label>{{ tab.title }}</ion-label>
                <ion-icon name="home"></ion-icon>
            </ion-tab-button>
        </ion-tab-bar>
    </template>
</ion-tabs>

Activity

michaeltintiuc

michaeltintiuc commented on May 27, 2019

@michaeltintiuc
Contributor

@xar what's the behaviour if the contents of the tabs are not ion-vue-router elements but a Vue component or simple HTML instead?

michaeltintiuc

michaeltintiuc commented on May 28, 2019

@michaeltintiuc
Contributor

@xar if you look closely, the contents of the router are now an empty comment, this is due to the fact that the router renders an empty node as it did not match the route you're currently on, this is ultimately an issue with the Vue router, you can save it's state though by doing this:

    <ion-tab tab="home" :routes="['tabs.home']">
      <keep-alive>
        <router-view name="home" />
      </keep-alive>
    </ion-tab>
  1. Using router-view instead of ion-vue-router
  2. Wrapping the above in keep-alive

The reason for switching to router-view is due to a hard requirement of the transition element being the parent of keep-alive as per the docs. Unfortunately this is what is powering ionic transitions in Vue.

xar

xar commented on May 29, 2019

@xar
Author

@michaeltintiuc aa, you are correct. I understand now. In the end I have used router-view and probably will end making some ionic like transitions other way

michaeltintiuc

michaeltintiuc commented on May 30, 2019

@michaeltintiuc
Contributor

I'll be working towards enabling keep-alive support for ionic-vue-router it is a nice feature to have

michaeltintiuc

michaeltintiuc commented on Jul 10, 2019

@michaeltintiuc
Contributor

I totally forgot to mention the PR here, it's been open for quite a few days now ;)
#18561

ionitron-bot

ionitron-bot commented on Jul 9, 2020

@ionitron-bot

Thanks for the issue! This issue is being closed due to inactivity. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

Thank you for using Ionic!

locked and limited conversation to collaborators on Jul 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @xar@michaeltintiuc@liamdebeasi

        Issue actions

          bug: Vue routing in tabs mode cause re-render · Issue #18292 · ionic-team/ionic-framework