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.

bug: (vue) Switching between tabs with a query string messes up route

See original GitHub issue

Prequisites

Ionic Framework Version

  • v4.x
  • v5.x
  • v6.x

Current Behavior

I have a url with a custom query param, i.e.: http://localhost:8080/meer?domain=dCWh5t1dnF.pwa.autosociaal.nl, which is the “meer” tab. When I go to the “start” tab the url changes to http://localhost:8080/start?domain=dCWh5t1dnF.pwa.autosociaal.nl. When I click the “meer” tab again it again changes back to http://localhost:8080/meer?domain=dCWh5t1dnF.pwa.autosociaal.nl. Now, when I click the start tab again it suddenly becomes: http://localhost:8080/startdomain=dCWh5t1dnF.pwa.autosociaal.nl?domain=dCWh5t1dnF.pwa.autosociaal.nl

I have this router lifecycle hook in place to make it happen:

router.beforeEach(async (to, from, next) => {
  if (from.query.domain && !to.query.domain) {
    next({ ...to, query: from.query });
    return;
  }

  next();
});

Expected Behavior

The pathname should just be start or meer, not startdomain

Steps to Reproduce

Create a tabs setup with this router lifecycle hook:

router.beforeEach(async (to, from, next) => {
  if (from.query.domain && !to.query.domain) {
    next({ ...to, query: from.query });
    return;
  }

  next();
});

In this app it is also reproducable: https://7cu0jmqxdb.appflowapp.com/tabs/tab1?domain=dCWh5t1dnF.pwa.autosociaal.nl - start clicking between the tabs and see the route pathname of tab1 change between the clicking to tab1domain

Code Reproduction URL

https://7cu0jmqxdb.appflowapp.com/tabs/tab1?domain=dCWh5t1dnF.pwa.autosociaal.nl

Ionic Info

Ionic:

   Ionic CLI       : 6.16.3 (/Users/bob/.config/yarn/global/node_modules/@ionic/cli)
   Ionic Framework : @ionic/vue 5.6.12

Utility:

   cordova-res : not installed globally
   native-run  : 1.4.0

System:

   NodeJS : v14.17.3 (/Users/bob/.nvm/versions/node/v14.17.3/bin/node)
   npm    : 6.14.13
   OS     : macOS Big Sur

Additional Information

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
liamdebeasicommented, Dec 1, 2021

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

npm install @ionic/vue@5.10.0-dev.202112011701.ac1402b @ionic/vue-router@5.10.0-dev.202112011701.ac1402b
1reaction
Predarioncommented, Dec 2, 2021

@liamdebeasi Works!

I just tested the dev build in the reproduction project as well as our actual project.

Thank you very much for your effort, I really appreciate it!

Read more comments on GitHub >

github_iconTop Results From Across the Web

bug: (vue) Switching between tabs with a query string messes ...
Same issue here, query params on a route within tabs are not working, when switching back to a tab. Navigate to tabs/tab1/subpage?exampleparam= ...
Read more >
Change vuetify tab with the route or query - Stack Overflow
I ran into this problem too and fixed it by using parseInt when handling the route: this.tab = parseInt(this.$route.query.tab).
Read more >
Backbone.js
Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable ...
Read more >
Get vue-router to change part of the query string ... - SteGriff
Vue -router's API for modifying the current route (URL) accepts a 'location' object which can specify a path , a named route via...
Read more >
Build a Basic CRUD App with Vue.js and Node | Okta Developer
This tutorial will take you step by step through scaffolding a Vue.js project, offloading secure authentication to Okta's OpenID Connect API ( ...
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