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: [Ionic v4] query params are getting lost when navigating between tabs

See original GitHub issue

Bug Report

Query params are getting lost when navigating back and forth between tabs when using the ion-tabs buttons.

Current behavior: When navigating between tabs and one of the views of the tabs has query params in its URL (http://www.examplepage.com/tab1?key=value), the query params are lost when navigating back to that particular Tab.

Example:

Expected behavior: Following the example above, I will expect the query params to be preserved when navigating back to the latest active view on Tab A.

Related code:

I did some investigation and I did notice that the Angular Router is properly saving the query params under the property savedExtras but the Ionic IonRouterOutlet API only refers to the URL without taking into the account the query params, like it can be checked in the code below from the IonRouterOutlet class.

/**
   * Returns the URL of the active page of each stack.
   */
  getLastUrl(stackId?: string): string | undefined {
    const active = this.stackCtrl.getLastUrl(stackId);
    return active ? active.url : undefined;
  }

I am not sure if this is the expected behavior or if the queryParams needs to be considered when getting the last Url.

Ionic info:

Ionic:

   ionic (Ionic CLI) : 4.2.1

System:

   NodeJS : v10.9.0
   npm    : 6.7.0
   OS     : macOS

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
liamdebeasicommented, Dec 11, 2019

Thanks for the issue! This bug has been resolved via https://github.com/ionic-team/ionic/pull/18493 and will be available in an upcoming release of Ionic Framework.

3reactions
yannbfcommented, Jul 18, 2019

@liamdebeasi I see there are two PRs that intend to fix this issue: #18740 and #18493. Is it possible to have someone from Ionic to review them?

Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

bug: [Ionic v4] query params are getting lost when navigating ...
Bug Report Query params are getting lost when navigating back and forth between tabs when using the ion-tabs buttons.
Read more >
Ionic Tabs not removing query parameters when navigating to ...
The above takes me to the a url like '/tabs/home?id=2'. However, when I click on the tabs and navigate to other tabs like...
Read more >
Pass navigation state object between ion-tabs - Ionic Forum
Hello! I am trying to implement navigation between tabs. I read the following documentation: https://ionicframework.com/docs/api/tab-button ...
Read more >
Location - Angular
It's better to use the Router.navigate() service to trigger route changes. Use Location only if you need to interact with or create normalized...
Read more >
Working with Angular 14 Router - Techiediaries
You can use the browser's URL to navigate between Angular components ... Easy access to route parameters and query parameters,; Resolvers, ...
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